我正在使用AppActivate 专注于已经在Firefox上打开的网页(不想打开新标签页或其他Firefox实例(。在此选项卡中,我想按getElementById
复制特定值并粘贴到新工作表上以通过电子邮件发送。有人可以帮忙吗?我尝试了不同的方法,但直到现在都没有奏效。
Sub startFirefox()
Dim appfile As String
Dim fftask As Double
appfile = "Firefox"
On Error Resume Next
AppActivate "Firefox"
If Err <> 0 Then
Err = 0
fftask = Shell(appfile, 1)
If Err <> 0 Then MsgBox "Cannot start FF" 'if firefox is not open going to open a new instance
End If
'2nd part that i need to get the values from web page
Dim varA, Url As String
Url = "example"
Dim Site As Object
Set Site = CreateObject("firefox.application")
Dim oHTMLDoc As Object
Set oHTMLDoc = Site.Document
varA = oHTMLDoc.getElementById("X5").Value
MsgBox varA 'here is not showing any value. I put the msgbox just to see if is getting any value
End Sub
没有Firefox.Application
这样的东西。所以它永远不会起作用。
程序员使用Internet Explorer - 可编程浏览器。所以使用Set site = CreateObject("InternetExplorer.Application")
使用 COM 时不需要AppActivate
,它有一大组规则阻止它为程序工作(它旨在防止程序窃取焦点(。