473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Printing a Word doc from Access

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
5 1495
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jeff Harbin | last post by:
I've got an ACCESS 2000 application that I'm developing. One of the outputs of this app will be to generate a series of 'jobs' which corresponds to a record in the database. Each record will be...
9
by: Tony Williams | last post by:
I have an Access database that we use as a document index system. The documents can be Word, Excel, pdf's etc I have a command button on a form that opens the document in whatever program is...
5
by: Stefania Scott | last post by:
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 =...
3
by: Grim Reaper | last post by:
I print mailing labels out of Access 2000 databases about 3 to 4 times a week. I have been having problems with one thing since I have been printing mailing labels. I print mailing labels by...
4
by: Jamey Shuemaker | last post by:
I've been looking for a way to do a duplex print job without a duplex printer. I reviewed some old posts about printing odd pages and found that most of them led to KB article 101075 or an export...
4
by: John | last post by:
I have code that opens and prints a report using the Adobe PDF printer driver. The problem is that Access VB executes the next step in code before the PDF "Printer" is done "printing". Since the...
16
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
3
by: David | last post by:
Hello, hope someone can help. I have a request to print word .doc check lists with selected records in Access for surgery procedure cards. I have hyperlinked the word doc's to a field in each...
1
by: belinda | last post by:
I have used the ff command but only get the date printout and have no clue whats wrong: 'Printing function ' - opening a Word template with bookmarks ' - read bookmarks list from template and...
2
by: Iain Wilson | last post by:
Hi Mike I have changed the code using Server.MapPath but to no avail. Prints the Adobe PDF document to the default local printer (I am running this localhost). I Have not run it on the server...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.