472,985 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,985 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 3234
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

1
by: Raju Joseph | last post by:
Hi All, I have a small problem at hand and am looking for suggestions. I have created a wrapper for word 2000 for our application which is in VB.NET 2003. Everything works fine in the sense...
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...
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...
1
by: Tom | last post by:
Hi, I've been looking for ideas on how to print Word RTFs (or RTFs that contain headers and footers) on the server, and I haven't really found any solution. I would like to implement this as...
4
by: selen | last post by:
Hello, My problem is that: I want to open a word document and writing something in it then save it.But it give me granting access error.and say that:To grant ASP.NET write access to a file,...
0
by: Youss33 | last post by:
I have a problem printing a word document from an ASP.NET application. the Application doesn't send an error back but the document is not printed and the document is kept open by the application...
1
by: rija | last post by:
Hi all, I would like to know how can I do to display print dialog so that the user can choose printer when printing word document object. Basically, I download rtf document on the HD and open...
0
by: waltonlv | last post by:
I have looked at several coding examples on printing an access report within VB, but am having a problem with the .OpenCurrentDatabase command. When executed, I get the message "Database is already...
1
by: Laurent Navarro | last post by:
Hi, I created a C# application which opens a Word document, fills some fields and sends the whole document to the printer. Everything is working great but I find the printing step very slow....
3
by: crashonyou | last post by:
hello again..i've been searching for quite some time now already looking for a solution to printing word documents with python..same thing for internet explorer..i was experimenting around with some...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.