1. FAQ
  2. 엑셀(Excel)
  3. AfterEffects
  4. Premiere
  5. Photoshop
  6. ETC

이 게시판은 아별닷컴 회원만 질문을 올릴 수 있습니다. 회원에게 주어지는 특권인셈이지요. 회원이 아닌 분들은 열람만 가능합니다.

회사내부 프로그램으로 엑셀로 데이터 EXPORT (다운로더) 하고 나면 인터넷 창이 하나 열립니다
 
대충 주소창에 이렇게 되어 있고
http://lgegltase9q.lge.com:8080/cgi-bin/excel_export_ui.cgi?session_id=162618041&columns=54
 
이런 주소로 열립니다(주소id 부분에 숫자는 계속 바뀌는거 같아요)  
매크로 실행으로 이창을 닫을수 잇는 방법이 있나요(다른 매크로 실행후 최종으로 창을 닫히게 하려고 합니다)
 
매번 EXPORT후 창을 당아야 하는 불편함이 있네요
 
하기 예제를 참조해서 몇일째 고생 하는데 안되고 있습니다

http://www.excelforum.com/excel-programming/475166-using-excel-vba-to-close-ie.html

아주 간단한 방법이 잇는지요?

xp , office2010 사용 합니다


댓글 '3'

profile

[레벨:30]아별

2013.04.08 11:36:11
*.104.126.21

맑은이슬님..


아주 간단한 방법은 없구요..

윈도우 API를 사용해야하구요.. 


FindWindow로  대상 IE창의 핸들값을 가져와야하고..

SendMessage로 창닫기 메시지를 보내줘야하는데..


일단.. FindWindow로 창의 핸들 값을 찾으려면 IE창의 정확한 캡션명을 알아야합니다.

아별닷컴의 경우 "ABYUL.COM > Movie > ABYUL - Windows Internet Explorer" 머 이런게 캡션명이죠..


암튼..

엑셀로 인터넷익스플로러의 창을 닫는 행위는 해보지 않아서..

테스트해보고 다시 답변드리겠습니다.


멀.. 이런걸 다.. 하하..

profile

[레벨:30]아별

2013.04.08 15:57:13
*.104.126.21

맑은이슬님..

참고로 링크해주신 곳의 코드를 테스트해보니..

잘 동작하는데요? ^_^;;


코드 아래 쪽에 test프로시저를 보시면.. 아래처럼 되어 있죠?

캡션명이 "Microsoft Internet Explorer"인 인터넷 익스플로러 창을 닫으라는 의미입니다.


Sub test()

    CloseApp "Microsoft Internet Explorer", "IEFrame"

End Sub


저걸 아래처럼 수정하면.. 캡션명이 "네이버"로 시작되는 인터넷 익스플로러 창을 닫아줍니다.

Sub test()

    CloseApp "네이버", "IEFrame"

End Sub


인터넷 익스플로러에서 네이버로 들어가신 다음 첨부파일을 실행해보세요..


다운받기 : VBA_인터넷익스플로러창닫기_closeIE.xlsm


Option Explicit


'### From. http://www.excelforum.com/excel-programming-vba-macros/475166-using-excel-vba-to-close-ie.html

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _

    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Declare Function GetDesktopWindow Lib "user32" () As Long

Private Declare Function GetWindow Lib "user32" _

    (ByVal hwnd As Long, ByVal wCmd As Long) As Long

Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _

    (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _

    (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Private Const GW_HWNDFIRST = 0

Private Const GW_HWNDLAST = 1

Private Const GW_HWNDNEXT = 2

Private Const GW_HWNDPREV = 3

Private Const GW_OWNER = 4

Private Const GW_CHILD = 5

Private Const WM_CLOSE = &H10


Function FindWindowHwndLike(hWndStart As Long, ClassName As String, _

        WindowTitle As String, level As Long, lHolder As Long) As Long

    'finds the first window where the class name start with ClassName

    'and where the Window title starts with WindowTitle, returns Hwnd

    '----------------------------------------------------------------

    Dim hwnd As Long

    Dim sWindowTitle As String

    Dim sClassName As String

    Dim r As Long

    'Initialize if necessary. This is only executed

    'when level = 0 and hWndStart = 0, normally

    'only on the first call to the routine.

    If level = 0 Then

        If hWndStart = 0 Then

            hWndStart = GetDesktopWindow()

        End If

    End If

    'Increase recursion counter

    level = level + 1

    'Get first child window

    hwnd = GetWindow(hWndStart, GW_CHILD)

    Do Until hwnd = 0

        'Search children by recursion

        lHolder = FindWindowHwndLike(hwnd, ClassName, _

                    WindowTitle, level, lHolder)

        'Get the window text

        sWindowTitle = Space$(255)

        r = GetWindowText(hwnd, sWindowTitle, 255)

        sWindowTitle = Left$(sWindowTitle, r)

        'get the class name

        sClassName = Space$(255)

        r = GetClassName(hwnd, sClassName, 255)

        sClassName = Left$(sClassName, r)

        If InStr(1, sWindowTitle, WindowTitle, vbBinaryCompare) > 0 And _

            sClassName Like ClassName & "*" Then

            FindWindowHwndLike = hwnd

            lHolder = hwnd

            Exit Function

        End If

        'Get next child window

        hwnd = GetWindow(hwnd, GW_HWNDNEXT)

    Loop

    FindWindowHwndLike = lHolder

End Function


Function CloseApp(ByVal strApp As String, _

                  ByVal strClass As String) As Long

    'will find a window based on:

    'the partial start of the Window title and/or

    'the partial start of the Window class

    'and then close that window

    'for example, this will close Excel:

    'CloseApp "", "XLM" and this will:

    'CloseApp "Microsoft Excel", ""

    'but this won't: CloseApp "", "LM"

    'it will only close the first window that

    'fulfills the criteria

    'will return Hwnd if successfull, and 0 if not

    '---------------------------------------------

    Dim hwnd As Long

    On Error GoTo ERROROUT

    hwnd = FindWindowHwndLike(0, strClass, strApp, 0, 0)

    If hwnd = 0 Then

        CloseApp = 0

        Exit Function

    End If

    'Post a message to the window to close itself

    '--------------------------------------------

    PostMessage hwnd, WM_CLOSE, 0&, 0&

    CloseApp = hwnd

    Exit Function

ERROROUT:

    On Error GoTo 0

    CloseApp = 0

End Function



Sub abCloseIEwithNaver()

    'CloseApp "Microsoft Internet Explorer", "IEFrame"

    CloseApp "네이버", "IEFrame"

    CloseApp "네이버", "Chrome_WidgetWin_1"

    CloseApp "네이버", "{1C03B488-D53B-4a81-97F8-754559640193}"

End Sub


Sub abNavigateNaver()

    ActiveSheet.Hyperlinks.Add Anchor:=Range("B2"), Address:= _

        "http://www.naver.com/", TextToDisplay:="http://www.naver.com/"

    Range("B2").Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True

End Sub 



첨부

[레벨:5]맑은이슬

2013.04.08 17:55:34
*.247.145.54

감사 합니다

좀더 공부를 해서 응용해야 할것 같습니다

문서 첨부 제한 : 0Byte/ 2.00MB
파일 제한 크기 : 2.00MB (허용 확장자 : *.*)
List of Articles
번호 제목 글쓴이 날짜 조회 수sort
공지 공지 [공지] 아별닷컴의 엑셀 질문방 폐쇄합니다. 카페 질문방 이용하세요.. imagefile [레벨:30]아별 2015-04-23 94048
542 엑셀일반 새해맞이 기념 연속채우기 관련 질문입니다. imagefile [2] [레벨:6]파이스 2013-01-03 5721
541 피벗테이블 엑셀 백분율 계산 등등~ file [3] [레벨:1]zzziniya 2011-09-23 5714
540 sum 함수 관련 질문있습니다~ [3] [레벨:1]모래요정 2009-08-27 5709
539 엑셀수식 안녕하세요 질문 좀 드리겠습니다 file [2] [레벨:1]달빛아래말할게 2014-10-20 5700
538 배열수식 배열수식_rank 질문 _ 2가지 조건으로 순위 정하기 file [4] [레벨:3]타케 2013-11-01 5698
537 수식이 잘못되어 틀린값이 나옵니다. 도와주십시오. file [1] [레벨:1]성택 2010-02-26 5694
536 엑셀일반 이중 데이터 유효성 검사에서 궁금한게 있습니다~ [레벨:1]새벽녘 2014-03-02 5692
535 엑셀일반 사진에있는 GPS메타정보추출 file [3] [레벨:1]얼씨구 2012-02-24 5683
534 엑셀일반 한가지 질문요 [레벨:1]싸이킥 2015-01-10 5672
533 VBA 2개의 시트를 비교하여 다른 부분을 찾아내는 프로시저 질문입니다! file [3] [레벨:6]파이스 2011-11-24 5672
532 차트 차트 질문 드립니다. file [3] [레벨:3]빛의행운아 2013-01-02 5668
531 VBA 외부 어플리케이션 실행 & 유저폼 일괄 닫기 & 리본 메뉴 사용자 추가 탭 숨기거나 보이게 하는 방법 [7] [레벨:3]엑셀대단해 2012-02-08 5657
530 엑셀 만게가 넘는 데이타에서 원하는 이하의 값 찾아내기 [3] [레벨:1]프라하 2009-09-03 5632
529 갯수 구하기 file [5] [레벨:5]눈물바다 2009-10-07 5624
» API 열려있는 ie창 닫기 _ Win32 API, SendMessage, FindWindows, WM_CLOSE [3] [레벨:5]맑은이슬 2013-04-06 5621
527 엑셀일반 엑셀 질문 몇가지 드립니다. file [1] [레벨:1]나도그래짱 2013-02-03 5589
526 엑셀 질문 file [2] 가넷 2009-12-16 5585
525 엑셀일반 혹시 이런것도 가능한가요? (간결한 2가지 질문) - VBA만 실행파일(.exe)로 만들 수 있는지 여부, 외부 파일명 일괄 변경 방법.. [2] [레벨:6]파이스 2011-12-02 5579
524 엑셀에서 Enter가 이상해요....ㅠ,,ㅠ [1] [레벨:2]리자딘 2009-07-15 5579
523 엑셀일반 중복 IF문 개념잡는법에 대한 질문 imagefile [4] [레벨:6]파이스 2014-05-19 5578