473,385 Members | 1,922 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,385 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 3291
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.