Greg Maxey was telling us:
Greg Maxey nous racontait que :
> JGM,
>
[quoted text clipped - 4 lines]
> The error occurs on the line:
> Set oWB = oXL.Workbooks.Open(FileName:=WorkbookToWorkOn)
Have you tried adding the line
oXL.Visible = True
just before the "Set oWB..." line just to make sure that the application was
indeed created properly?
> I know now why the error is thrown.
>
> For some reason the following code is not throwing an error as the
> code indicates it should if Excel is "not" already opened:
You mean that "If Err" is False when there are no Excel application running?
Are you sure you do not have an invisible application running (Sometimes an
Office application is not present in the Applications tab of the Windows
Task Manager, but is actually present in the Processes tab).
> 'If Excel is running, get a handle on it; otherwise start a new
> instance of Excel
[quoted text clipped - 4 lines]
> Set oXL = New Excel.Application
> End If
I ran the code as is form the web site (Just changed the path/name of the
Excel file) and it ran without any problems, even when Excel was not
previously running.
Then, as a test. I used a wrong path, and the error was caught as it was
supposed to.

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Greg Maxey - 18 Oct 2006 17:44 GMT
Hi JGM
"Are you sure you do not have an invisible application running
(Sometimes an
Office application is not present in the Applications tab of the
Windows Task Manager, but is actually present in the Processes tab)."
Knowledge is a wonderful thing isnt' it ;-)
> Greg Maxey was telling us:
> Greg Maxey nous racontait que :
[quoted text clipped - 19 lines]
>
> You mean that "If Err" is False when there are no Excel application running?
> > 'If Excel is running, get a handle on it; otherwise start a new
> > instance of Excel
[quoted text clipped - 18 lines]
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org