J
Jonathan Sachs
I would proceed as follows.
If this can be made to work, it may imply a solution to a
long-standing problem of mine. I tried strenuously to solve this
problem last year, but I was finally persuaded that it was unsolvable.
The problem is how to get access to a running instance of Internet
Explorer if one exists, OR create one if not. The first part is the
killer. I ended up with code which creates a new instance every time
it is run, whether needed or not.
Since I worked on this a year ago I no longer remember details about
what I tried or what went wrong. Here's the code I've got now.
Private Const browserName As String = "InternetExplorer.Application"
Public WithEvents explorerObject As InternetExplorer
Private Sub class_initialize()
Dim objErr As String
On Error Resume Next
Set explorerObject = GetObject(, browserName)
If Err.number <> 0 Or TypeName(explorerObject.Document) <>
"HTMLDocument" Then
Err.Clear
Set explorerObject = CreateObject(browserName)
If Err.number <> 0 Then
objErr = Err.Description
Err.Clear
End If
End If
On Error GoTo 0
If objErr <> "" Then
MsgBox "Cannot load the browser " + browserName + vbCr + _
"Create error:" + vbTab + objErr, vbOKOnly
End
End If
explorerObject.Visible = True
End Sub
I encountered this problem with Word 2000 under Windows 2000, and I'm
now using Word XP under Windows XP, if that helps.
My mail address is jsachs177 at earthlink dot net.
1. Make sure that there is no copy of Word running.
2. Start a copy using the command-line
3. Hook up to it using the GetObject command (or its equivalent in the
language you are using)
If this can be made to work, it may imply a solution to a
long-standing problem of mine. I tried strenuously to solve this
problem last year, but I was finally persuaded that it was unsolvable.
The problem is how to get access to a running instance of Internet
Explorer if one exists, OR create one if not. The first part is the
killer. I ended up with code which creates a new instance every time
it is run, whether needed or not.
Since I worked on this a year ago I no longer remember details about
what I tried or what went wrong. Here's the code I've got now.
Private Const browserName As String = "InternetExplorer.Application"
Public WithEvents explorerObject As InternetExplorer
Private Sub class_initialize()
Dim objErr As String
On Error Resume Next
Set explorerObject = GetObject(, browserName)
If Err.number <> 0 Or TypeName(explorerObject.Document) <>
"HTMLDocument" Then
Err.Clear
Set explorerObject = CreateObject(browserName)
If Err.number <> 0 Then
objErr = Err.Description
Err.Clear
End If
End If
On Error GoTo 0
If objErr <> "" Then
MsgBox "Cannot load the browser " + browserName + vbCr + _
"Create error:" + vbTab + objErr, vbOKOnly
End
End If
explorerObject.Visible = True
End Sub
I encountered this problem with Word 2000 under Windows 2000, and I'm
now using Word XP under Windows XP, if that helps.
My mail address is jsachs177 at earthlink dot net.