在Excel VBA中截图网页可以使用Internet Explorer 对象,您可以打开Internet Explorer,加载网页,然后使用其ShapeRange属性将截图复制到工作表单元格中。
以下是一个简单的代码示例:
Sub WebPageScreenShot() Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") With ie .Navigate " www.google.com " .Visible = True While .Busy Or .ReadyState <> 4 DoEvents .Top = 0 .Left = 0 .Width = 800 .Height = 600 .Document.body.createTextRange.execCommand "SaveAs", False, "C:\Google.jpg" .Quit End With Set ie = Nothing End Sub