使用宏拍摄网站截图,然后将其粘贴

时间:2018-10-10 08:58:15

标签: vba ms-word webpage-screenshot

我正在尝试获取下面链接的网页的屏幕截图,然后将其粘贴到word中。我有一些代码应该执行此操作,但是每次运行它都会出现一个hwnd = 0错误窗口。有人可以指出我要去哪里了。

网页:https://www.makro.co.za/groceries-and-toiletries/protex-/br-soap-deep-clean-/br-1-x-150g--338971001EA

Sleep 5000

'~~> Get the caption of IE
IECaption = "Protex Soap Deep Clean (1 x 150g)- Lowest Prices & Specials Online | Makro - Internet Explorer"

'~~> Get handle of IE
hwnd = FindWindow(vbNullString, IECaption)

If hwnd = 0 Then
    MsgBox "IE Window Not found!"
    Exit Sub

1 个答案:

答案 0 :(得分:0)

ShellWindows是Internet Explorer和File Explorer窗口。

Set objShell = CreateObject("Shell.Application")
Set AllWindows = objShell.Windows
For Each window in AllWindows
    msgbox window.locationname & vbcrlf & typename(window.parent) & vbcrlf & window.name
Next

或者上面的window对象是IE对象。

Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate2 "www.google.com.au"
ie.visible=true
wscript.sleep 5000
ie.refresh2