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

Printing a Word doc from Access

P: n/a
I am trying to print a word document from Access. The code I've
written works well in my computer but does not in the one were it is
needed.
Here the piece of code:
'doc path
strObjectPath = "P:\2004worksheets\IIS_WS.doc"

Set oWord = New Word.Application
oWord.Documents.Add (strObjectPath)
oWord.PrintOut
oWord.Quit SaveChanges:=0
Set oWord = Nothing

In my computer the document prints correctly and the fields in word
that are linked to a tmpTable in Access are correctly refreshed.
In the other computer the document prints without refreshing.
I tried several thingd such as:
Set oWord = New Word.Application
oWord.Documents.Add (strObjectPath)
'added this line to update fields in the word doc
oWord.ActiveDocument.Fields.Update
oWord.PrintOut
oWord.Quit SaveChanges:=0

Another problem is that in the other computer the print Icon appeared
but the document was not printing, I resolved the problem by adding a
message box between PrintOut and Quit line and this has resolved the
printing problem but not the refreshing of the linked fields.

If any one has any idea regarding what's going on I will really
appreciate it.

Thanks,

Stefania
Set oWord = Nothing
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 20 Apr 2004 13:49:44 -0700, st******@u.arizona.edu (Stefania Scott)
wrote:
I am trying to print a word document from Access. The code I've
written works well in my computer but does not in the one were it is
needed.
Here the piece of code:
'doc path
strObjectPath = "P:\2004worksheets\IIS_WS.doc"

Set oWord = New Word.Application
oWord.Documents.Add (strObjectPath)
oWord.PrintOut
oWord.Quit SaveChanges:=0
Set oWord = Nothing

In my computer the document prints correctly and the fields in word
that are linked to a tmpTable in Access are correctly refreshed.
In the other computer the document prints without refreshing.
I tried several thingd such as:
Set oWord = New Word.Application
oWord.Documents.Add (strObjectPath)
'added this line to update fields in the word doc
oWord.ActiveDocument.Fields.Update
oWord.PrintOut
oWord.Quit SaveChanges:=0

Another problem is that in the other computer the print Icon appeared
but the document was not printing, I resolved the problem by adding a
message box between PrintOut and Quit line and this has resolved the
printing problem but not the refreshing of the linked fields.

If any one has any idea regarding what's going on I will really
appreciate it.

Thanks,

Stefania


On the other computer, change the Word option under:

Tools|Options|Print|Update Fields so that it matches yours.

mike
Nov 12 '05 #2

P: n/a
Mike,
Thank you for your reply.
Before posting the help message I had already checked the printing
options and it did not work; the all thing is driving me nuts.
Furthermore, there is the fact that if I do not put the msgbox between
printout and quit in the other computer you see the printing icon
appear but the document does not get printed, why?. Any other possible
suggestion on the matter?

Stefania

mb**************@pacbell.net (Mike Preston) wrote in message news:<40****************@news.INDIVIDUAL.NET>...
On 20 Apr 2004 13:49:44 -0700, st******@u.arizona.edu (Stefania Scott)
wrote:
I am trying to print a word document from Access. The code I've
written works well in my computer but does not in the one were it is
needed.
Here the piece of code:
'doc path
strObjectPath = "P:\2004worksheets\IIS_WS.doc"

Set oWord = New Word.Application
oWord.Documents.Add (strObjectPath)
oWord.PrintOut
oWord.Quit SaveChanges:=0
Set oWord = Nothing

In my computer the document prints correctly and the fields in word
that are linked to a tmpTable in Access are correctly refreshed.
In the other computer the document prints without refreshing.
I tried several thingd such as:
Set oWord = New Word.Application
oWord.Documents.Add (strObjectPath)
'added this line to update fields in the word doc
oWord.ActiveDocument.Fields.Update
oWord.PrintOut
oWord.Quit SaveChanges:=0

Another problem is that in the other computer the print Icon appeared
but the document was not printing, I resolved the problem by adding a
message box between PrintOut and Quit line and this has resolved the
printing problem but not the refreshing of the linked fields.

If any one has any idea regarding what's going on I will really
appreciate it.

Thanks,

Stefania


On the other computer, change the Word option under:

Tools|Options|Print|Update Fields so that it matches yours.

mike

Nov 12 '05 #3

P: n/a
Mike,
I have noticed the following:
when I open the word document from the computer where the automation
does not work I get the message following message:
Microsoft Word
Opening this document will run the following SQL command:
SELECT * FROM tmpWorkSheet
Data from your database will be placed in the document. Do you want to
continue?
Yes No

Is it possible that this is the cause of the problem, if so how do I
fix it?

Thanks again,

Stefania

mb**************@pacbell.net (Mike Preston) wrote in message news:<40****************@news.INDIVIDUAL.NET>...
On 20 Apr 2004 13:49:44 -0700, st******@u.arizona.edu (Stefania Scott)
wrote:
I am trying to print a word document from Access. The code I've
written works well in my computer but does not in the one were it is
needed.
Here the piece of code:
'doc path
strObjectPath = "P:\2004worksheets\IIS_WS.doc"

Set oWord = New Word.Application
oWord.Documents.Add (strObjectPath)
oWord.PrintOut
oWord.Quit SaveChanges:=0
Set oWord = Nothing

In my computer the document prints correctly and the fields in word
that are linked to a tmpTable in Access are correctly refreshed.
In the other computer the document prints without refreshing.
I tried several thingd such as:
Set oWord = New Word.Application
oWord.Documents.Add (strObjectPath)
'added this line to update fields in the word doc
oWord.ActiveDocument.Fields.Update
oWord.PrintOut
oWord.Quit SaveChanges:=0

Another problem is that in the other computer the print Icon appeared
but the document was not printing, I resolved the problem by adding a
message box between PrintOut and Quit line and this has resolved the
printing problem but not the refreshing of the linked fields.

If any one has any idea regarding what's going on I will really
appreciate it.

Thanks,

Stefania


On the other computer, change the Word option under:

Tools|Options|Print|Update Fields so that it matches yours.

mike

Nov 12 '05 #4

P: n/a
On 21 Apr 2004 07:29:03 -0700, st******@u.arizona.edu (Stefania Scott)
wrote:
Mike,
Thank you for your reply.
Before posting the help message I had already checked the printing
options and it did not work; the all thing is driving me nuts.
Furthermore, there is the fact that if I do not put the msgbox between
printout and quit in the other computer you see the printing icon
appear but the document does not get printed, why?. Any other possible
suggestion on the matter?
I'm not going to be much help at this point, I'm afraid.

It sounds like the other computer's setup is significantly different
from yours. The msgbox insertion seems to slow things down enough for
the printing to take place before the Access VBA finishes. I would
think the "oWord.PrintOut" command would be interpreted by Word as
something that must be completed before it would allow the "oWord.Quit
SaveChanges:=0" to be executed, but obviously not.

Again, it points to Word's set-up on the offending computer. Is there
an option that disallows background printing?

mike


Stefania

mb**************@pacbell.net (Mike Preston) wrote in message news:<40****************@news.INDIVIDUAL.NET>...
On 20 Apr 2004 13:49:44 -0700, st******@u.arizona.edu (Stefania Scott)
wrote:
>I am trying to print a word document from Access. The code I've
>written works well in my computer but does not in the one were it is
>needed.
>Here the piece of code:
> 'doc path
> strObjectPath = "P:\2004worksheets\IIS_WS.doc"
>
> Set oWord = New Word.Application
> oWord.Documents.Add (strObjectPath)
> oWord.PrintOut
> oWord.Quit SaveChanges:=0
> Set oWord = Nothing
>
>In my computer the document prints correctly and the fields in word
>that are linked to a tmpTable in Access are correctly refreshed.
>In the other computer the document prints without refreshing.
>I tried several thingd such as:
>
>
> Set oWord = New Word.Application
> oWord.Documents.Add (strObjectPath)
>'added this line to update fields in the word doc
> oWord.ActiveDocument.Fields.Update
> oWord.PrintOut
> oWord.Quit SaveChanges:=0
>
> Another problem is that in the other computer the print Icon appeared
>but the document was not printing, I resolved the problem by adding a
>message box between PrintOut and Quit line and this has resolved the
>printing problem but not the refreshing of the linked fields.
>
>If any one has any idea regarding what's going on I will really
>appreciate it.
>
>Thanks,
>
>Stefania


On the other computer, change the Word option under:

Tools|Options|Print|Update Fields so that it matches yours.

mike


Nov 12 '05 #5

P: n/a
On 21 Apr 2004 08:19:15 -0700, st******@u.arizona.edu (Stefania Scott)
wrote:
Mike,
I have noticed the following:
when I open the word document from the computer where the automation
does not work I get the message following message:
Microsoft Word
Opening this document will run the following SQL command:
SELECT * FROM tmpWorkSheet
Data from your database will be placed in the document. Do you want to
continue?
Yes No

Is it possible that this is the cause of the problem, if so how do I
fix it?
Well, it seems like the other computer's Word is set up to mandate
some form of validation before the fields are updated. That could
certainly explain why the automation code doesn't update the fields -
it isn't providing the proper validation.

Again, it looks like the Word installation on the offending computer
is the culprit. Maybe a word newsgroup would be more familiar with
the issues.

mike

mb**************@pacbell.net (Mike Preston) wrote in message news:<40****************@news.INDIVIDUAL.NET>...
On 20 Apr 2004 13:49:44 -0700, st******@u.arizona.edu (Stefania Scott)
wrote:
>I am trying to print a word document from Access. The code I've
>written works well in my computer but does not in the one were it is
>needed.
>Here the piece of code:
> 'doc path
> strObjectPath = "P:\2004worksheets\IIS_WS.doc"
>
> Set oWord = New Word.Application
> oWord.Documents.Add (strObjectPath)
> oWord.PrintOut
> oWord.Quit SaveChanges:=0
> Set oWord = Nothing
>
>In my computer the document prints correctly and the fields in word
>that are linked to a tmpTable in Access are correctly refreshed.
>In the other computer the document prints without refreshing.
>I tried several thingd such as:
>
>
> Set oWord = New Word.Application
> oWord.Documents.Add (strObjectPath)
>'added this line to update fields in the word doc
> oWord.ActiveDocument.Fields.Update
> oWord.PrintOut
> oWord.Quit SaveChanges:=0
>
> Another problem is that in the other computer the print Icon appeared
>but the document was not printing, I resolved the problem by adding a
>message box between PrintOut and Quit line and this has resolved the
>printing problem but not the refreshing of the linked fields.
>
>If any one has any idea regarding what's going on I will really
>appreciate it.
>
>Thanks,
>
>Stefania


On the other computer, change the Word option under:

Tools|Options|Print|Update Fields so that it matches yours.

mike


Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.