使用VBA的完整网页的屏幕截图

时间:2019-07-17 07:51:15

标签: excel vba

我要拍摄Fallowing网页的屏幕截图

https://www.nseindia.com/live_market/dynaContent/live_watch/option_chain/optionKeys.jsp?symbolCode=-9999&symbol=BANKNIFTY&symbol=BANKNIFTY&instrument=-&date=-&segmentLink=17&symbolCount=2&segmentLink=17

但是屏幕截图仅显示可见窗口

有什么办法拍摄完整的网页截图

我的代码:

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

Private Const VK_SNAPSHOT As Byte = 44

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Const SW_SHOWMAXIMIZED = 3
Private Const VK_LCONTROL As Long = &HA2
Private Const VK_V = &H56
Private Const KEYEVENTF_KEYUP = &H2

Sub Test() 
    MP = ActiveWorkbook.Name
    Dim IE As New SHDocVw.InternetExplorer

    IE.Visible = True
    IE.navigate "https://www.nseindia.com/live_market/dynaContent/live_watch/option_chain/optionKeys.jsp?symbolCode=-9999&symbol=BANKNIFTY&symbol=BANKNIFTY&instrument=-&date=-&segmentLink=17&symbolCount=2&segmentLink=17"
    ShowWindow IE.hwnd, SW_SHOWMAXIMIZED

    Do While IE.readyState <> READYSTATE_COMPLETE
    Loop

    Call keybd_event(VK_SNAPSHOT, 0, 0, 0)

    Windows(MP).Activate
    Range("A1").Select
    ActiveSheet.Paste
End Sub

我需要完整的屏幕截图,如所附图片:

enter image description here

0 个答案:

没有答案