Starting Excel via CreateObject
Posted on 2001-06-21
I want to start up and display an instance of Excel 97 from my VB 5.0 project. Should be easy, right? I've been trying to use the same Automation concept with Excel that has always worked OK with Word 97, like this:
(Reference to MS Excel 8.0 Library established first)
Dim xl As Excel.Application
Set xl = CreateObject("Excel.Application")
xl.Visible = True
'More code to manipulate xl . . .
Set xl = Nothing
PROBLEM: The code stops on the "CreateObject" line with, "Run-Time Error 429: ActiveX component can't create object."
BUT, if I change the Set Statement to use the New keyword instead of CreateObject:
Set xl = New Excel.Application
then Excel starts, but minimized (I have to use xl.WindowState=xlNormal to get it displayed. Seems strange, but I could live with it).
Anybody got any ideas why the CreateObject approach is not working with Excel? Microsoft dox say it outta work.