How to open Word from Excel with VBA (Office 2003)

  • Thread starter Thread starter Daniel Hohenberger
  • Start date Start date
D

Daniel Hohenberger

Hi.
I'm trying to build a organization chart from data I have in a excel sheet. As I
understand http://support.microsoft.com/default.aspx/kb/317293/en-us I need to
open Word to create the chart there and then copy'n'paste it to my excel file.

When trying to run the demo code, Excel just aborts without as much as an error
dialog. when debugging, I found out it only goes to the line
Set oCurWorkApplObj = CreateObject("Word.Application")

and then nothing happens. In debugging mode, it just restarts from the beginning
after that line.

Can anyone here give me a hint, what might go wrong or what I might do to find
out what exactly goes wrong?

Thanks in advance,
Daniel
 
try rebooting your system and trying it.

If word is registered and closed when you run the code, it should work.

It is possible you have started multiple instances of word and they are
taking up all your memory. You can use task manager to see before you
reboot.
 
Hi Tom,

thank you for the quick response. There were no Word instances running according
to my task manager. I tried rebooting nonetheless, but to no avail.

Word is closed, but I'm not sure what you mean by 'registered'. Do I need to do
this somewhere in VBA? Need I declare the use of Word before using this sub? I'm
sorry if this sounds stupid, I'm a total beginner with VBA, only used to Java and C.

Regards,
Daniel
 
No, you shouldn't need to register it. If you want to check, go into the VBE
(alt+F11) and go to tools =>References and see if Microsoft Word is listed
there. If it is, then it is registered. In fact, create a reference to it.

then in your code you can change

Set oCurWorkApplObj = CreateObject("Word.Application")

to

Set oCurWorkApplObj = new word.Application

http://word.mvps.org/FAQs/InterDev/EarlyvsLateBinding.htm
 
Just wondering if you looked in the task manager on the Application tab or did
you look for WINWORD.exe on the Processes tab?
 
Thanks again,

that did the trick. Now onwards to actually getting the needed data from the xls
and pretty colors ;)

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top