彰化一整天的論壇

 找回密碼
 立即註冊
查看: 234|回復: 3

老師請問調整IE到100%

[複製鏈接]
發表於 2018-12-1 10:41:20 | 顯示全部樓層 |閱讀模式
老師請問調整IE到100%能不能調整完自動關閉IE
我有試過但會出現錯誤
#If VBA7 Or Win64 Then
        Declare PtrSafe Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    #Else
        Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

    #End If


    Global Const SW_MAXIMIZE = 3
    Global Const SW_SHOWNORMAL = 1
    Global Const SW_SHOWMINIMIZED = 2

    Sub open_ie_max()
        Dim objIE As Object
        Call ChangeRegistry
        Set objIE = CreateObject("InternetExplorer.Application")
        objIE.Visible = True
        apiShowWindow objIE.hwnd, SW_MAXIMIZE
        objIE.navigate "http://blog.bestdaylong.com"
    End Sub
    Function ChangeRegistry()
    Dim objShell
    Set objShell = CreateObject("WScript.Shell")
    objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom\ZoomFactor", "100000", "REG_DWORD"
    Set objShell = Nothing
    End Function




'將ie關閉
    ie.Quit
'   For Each oHTML_Element In ie.document.getElementsByTagName("input")
'      If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For
'   Next      <-----這段放不進去會出現錯誤



回復

使用道具 舉報

發表於 2018-12-1 11:04:12 | 顯示全部樓層
您的變數名稱不同,要一樣才可以關閉
  1. #If VBA7 Or Win64 Then
  2.     Declare PtrSafe Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
  3. #Else
  4.     Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

  5. #End If


  6. Global Const SW_MAXIMIZE = 3
  7. Global Const SW_SHOWNORMAL = 1
  8. Global Const SW_SHOWMINIMIZED = 2

  9. Sub open_ie_max()
  10.     Dim objIE As Object
  11.     Call ChangeRegistry
  12.     Set objIE = CreateObject("InternetExplorer.Application")
  13.     objIE.Visible = True
  14.     apiShowWindow objIE.hwnd, SW_MAXIMIZE
  15.     objIE.navigate "http://blog.bestdaylong.com"
  16.    
  17.     If MsgBox("是否要關閉IE", vbYesNo) = vbYes Then
  18.         objIE.Quit
  19.     End If
  20.    
  21. End Sub
  22. Function ChangeRegistry()
  23.     Dim objShell
  24.     Set objShell = CreateObject("WScript.Shell")
  25.     objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom\ZoomFactor", "100000", "REG_DWORD"
  26.     Set objShell = Nothing
  27. End Function

複製代碼


open_ie_max.xls

40 KB, 下載次數: 0

售價: 1 金錢  [記錄]  [購買]

回復 支持 反對

使用道具 舉報

 樓主| 發表於 2018-12-1 11:15:58 | 顯示全部樓層
老師這個是用詢問方式的有那個自動關不或幾秒後關閉的嗎
回復 支持 反對

使用道具 舉報

發表於 2018-12-1 11:22:09 | 顯示全部樓層
windbjo4 發表於 2018-12-1 11:15
老師這個是用詢問方式的有那個自動關不或幾秒後關閉的嗎
  1. #If VBA7 Or Win64 Then
  2.     Declare PtrSafe Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
  3. #Else
  4.     Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

  5. #End If


  6. Global Const SW_MAXIMIZE = 3
  7. Global Const SW_SHOWNORMAL = 1
  8. Global Const SW_SHOWMINIMIZED = 2

  9. Sub open_ie_max()
  10.     Dim objIE As Object
  11.     Call ChangeRegistry
  12.     Set objIE = CreateObject("InternetExplorer.Application")
  13.     objIE.Visible = True
  14.     apiShowWindow objIE.hwnd, SW_MAXIMIZE
  15.     objIE.navigate "http://blog.bestdaylong.com"

  16.     Application.Wait (Now + TimeValue("0:00:05"))   '等5秒
  17.    
  18.     objIE.Quit

  19.    
  20. End Sub
  21. Function ChangeRegistry()
  22.     Dim objShell
  23.     Set objShell = CreateObject("WScript.Shell")
  24.     objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom\ZoomFactor", "100000", "REG_DWORD"
  25.     Set objShell = Nothing
  26. End Function
複製代碼
回復 支持 反對

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

 ㄚ母滴雞湯
 員林香純滴雞精

Archiver|手機版|小黑屋|彰化一整天的論壇(Excel,Office)  |网站地图

GMT+8, 2019-8-25 21:19 , Processed in 0.117082 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表