Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoEvents not helpful, need to suspect action

Status
Not open for further replies.

ycim

Programmer
Feb 9, 2005
95
CA
I am working with a program to automate Word to create documents from Access. When the user is in access and says "Create Letter" (by way of a command button), I need a popup screen to say "Please wait..creating document name???".

Then in the background it should go to word (quietly in the background) and create the document. It does do all of this, but the issue I am having is with the popup screen.

If I don't set DoEvents, then it just draws the frame and leaves the inside of it transparent.

If I use the DoEvents, it displays the screen only the first time, and then shows word opening and closing and doing all the commands that I have set up in the background. I don't want the user to see all the Word activity.

Using a sleep API is not helpful either as you have to program the amount of sleep time. How would I set this when the speed will vary from machine to machine?

My question....any suggestions how I can get my "please wait" popup screen to appear, and only that screen, that will provide the user with visual updates as to the progress in the background?

Perhaps there is a way to use sleep, but I am unfamiliar with it (other than reading it through the forums here).

If anyone has any suggestions, I am all ears!
 
I don't want the user to see all the Word activity
yourWordAppObject.Visible = False

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
One suggestion would be to
1. Open the wait form
2. On that forms activate event do your word processing.

some code I use for creating an excel document. Should be similar to what you are doing with word. The key is the bolded part.

Set oExcelApp = CreateObject("EXCEL.APPLICATION")
oExcelApp.Visible = False
oExcelApp.Workbooks.Open FileName:=sXlsTemplate, ReadOnly:=True, ignoreReadOnlyRecommended:=True
Set oWs = oExcelApp.ActiveSheet
Set oWb = oExcelApp.ActiveWorkbook

bla bla bla


When processing is finished

oExcelApp.Visible = True

and close your wait form.

Andy Baldwin

"Testing is the most overlooked programming language on the books!"

Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.
 
Sorry Phv. Got a call in the middle of posting.

Andy Baldwin

"Testing is the most overlooked programming language on the books!"

Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.
 
I have set it to .visible = false. However, the screen still "blips" up word momentarily, every time a file is opened, and then it shows the application "mostly" again. By mostly, I mean that it draws about 80% of the screen.

For info sake, what happens in the background is that I set a recordset and it loops through the recordset. Each record has a document assigned to it (by way of text field). To automate word, I do the following...

--open word
--create a master document from a template

Loop starts here
--open the document laid out in the current record in the recordset
--append the contents of that document to the master document
Loop 'through the recordset again

Everytime I open the document from the recordset, I get the word screen blipping up and then hiding itself when it hits the .visible property. I set the .visible property after each wd.open statement.

I am looking for something that will completely hide the word activity.

Any further thoughts?
 
Looks like we were all thinking at the same time! Let me try abaldwin fix, and I will let you know shortly the results!
 
Can you post your code at least down to where you are opening the word document. I dont care about the actual processing but it sounds like you are opening a document rather than creating a word application object, making it invisible, and then processing. I do this with excel all the time and only after the processing does excel become visible with no "blinking"
This could be because you actually instruct Word to OPen and then make it invisible.


Andy Baldwin

"Testing is the most overlooked programming language on the books!"

Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.
 
You were most helpful! When I went to grab my code to post, I realized my error!

Thank you for your help! It now works like a charm!
 
who was most helpful? What was your error? Just in case anyone else looks into this post.


Andy Baldwin

"Testing is the most overlooked programming language on the books!"

Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.
 
Sorry....I didn't open up the word document correctly. I changed my open statement to be as follows: (I have deleted the old stuff, so I hope I remember it correctly!)

Code:
Dim wd as Word.application
Set docOrig = wd.Documents.Open(Filename:=strDocName)

I had first done it this way...

Code:
Dim wd as word.application
Dim docOrig as wd.document
docorig.open(filename:=strdocname)

I am new to Word automation, so I thought that the first way was correct, but changing the code to the second way has made all the difference.

On second thought, why would that be? It brings to light a good question, as I will be using word automation quite a bit in the future.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top