Solved

VB Word control

Posted on 2002-03-21
8
159 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:srobia
8 Comments
 
LVL 1

Expert Comment

by:COAtheGREAT
ID: 6885560
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
 

Author Comment

by:srobia
ID: 6885565
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
 
LVL 1

Expert Comment

by:COAtheGREAT
ID: 6885641
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
 
LVL 44

Expert Comment

by:bruintje
ID: 6886120
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:srobia
ID: 6886760
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
 
LVL 1

Expert Comment

by:COAtheGREAT
ID: 6886898
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 7634218
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
 
LVL 1

Accepted Solution

by:
kodiakbear earned 0 total points
ID: 7666093
Moving to the Paq

kb
Experts Exchange Moderator
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Mysql vs Oracle 10 120
Window placement 17 65
using web browser with BING 40 86
Modifying Conditional Format from VBA code 3 31
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now