By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
461,994 Members | 550 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 461,994 IT Pros & Developers. It's quick & easy.

error using GetObject - "cannot create ActiveX component"

P: 9
Hi,

I'm trying to do a mail merge from Excel to Word (programatically) and I'm having some trouble creating the Word Document Object. This line of code
wordDoc = GetObject("sheet.doc")
keeps returning the error "cannot create ActiveX component" and then the program crashes.
Any help is much appreciated. Thank you.

Larry
Aug 15 '07 #1
Share this Question
Share on Google+
2 Replies

P: 82
Hi,

I'm trying to do a mail merge from Excel to Word (programatically) and I'm having some trouble creating the Word Document Object. This line of code
wordDoc = GetObject("sheet.doc")
keeps returning the error "cannot create ActiveX component" and then the program crashes.
Any help is much appreciated. Thank you.

Larry
Hi -

I think you're doing shortcut here. You have to had word application open first.
wordDoc = GetObject("Word.Application")

if above code raises an error, you have to code
wordDoc = CreateObject("Word.Application")

and from here, try to open "sheet.doc"
Aug 16 '07 #2

P: 9
Thank you for the help.

I was actually able to get it to work using the GetObject call. I think it needed the full path of the file to open.
However, when I try to run the program from a C++ program, it doesn't work. Do you know anything about that?

Thanks, Larry

Hi -

I think you're doing shortcut here. You have to had word application open first.
wordDoc = GetObject("Word.Application")

if above code raises an error, you have to code
wordDoc = CreateObject("Word.Application")

and from here, try to open "sheet.doc"
Aug 16 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.