VB Word control

Fom VB I launch a word document and run a macro within that document.  The macro can take some time,  how do I give my VB application back control after I launch the word document.  The application doesn't really care if the word macro completes or fails.  Currently, the VB app has to wait for word to complete before control can be given.

Dim objNewDoc
Set objNewDoc = oWord.Documents.Add(WORKING_DIR & _ "\templates\" & s_reportlocation)

oWord.Visible = True


objNewDoc.PopulateDocument
         
Unload Me
   
'Kill all of the word related objects
Set objNewDoc = Nothing
Set oWord = Nothing
srobiaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
kodiakbearConnect With a Mentor Commented:
Moving to the Paq

kb
Experts Exchange Moderator
0
 
COAtheGREATCommented:
Try using the timer in macro. Wen you call the function it enabled timer control so you get out of function, and on timer event you do what you need.
0
 
srobiaAuthor Commented:
I'm not sure I know what you mean -- how would I launch the macro to do the program?  Or would I call the timer macro and in the timer macro launch the other macro?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
COAtheGREATCommented:
You can insert UserForm in word document and plase on it timer control. On timer event do jour work. Your word macro just enables timer.
0
 
bruintjeCommented:
Hi srobia, instead of creating the process like that, for background processing i would use the shell command

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q129796

word has some commandline switches and one of tehm is to start with a macro /m + macroname so for example WORKING_DIR & _ "\templates\" & s_reportlocation & " /m" & PopulateDocument

HTH:O)Bruintje
0
 
srobiaAuthor Commented:
bruintje -- I like the idea -- and I tried it.  However, I need to populate bookmarks from the VB application.  So unfortunately, I need to be able to launch word with a reference for the VB app to call and populate bookmarks.

COAtheGREAT -- can you give an example -- I think I understand I just want to make sure.  Thanks,
0
 
COAtheGREATCommented:
I am afraid i wos wrong i cant find the timer in word, but try to use idea if you can. Or you can use win api but it is harder way because you must create threed.
0
 
DanRollinsCommented:
Hi srobia,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

srobia, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.