Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Need VBA help

in my macro, I print several tabs and they print a certain order. I'm trying
to open a word doc and print it to my color printer. The macro changes the
printer to the color one, but when I run the macro, the word doc doesn't
print at all. Any help is appreciated. I have created the reference under
(tools/reference). My code is below: Thanks.

On Error Resume Next
Application.ActivePrinter = "HP C LaserJet 4550N PCL6 on Ne01:"
If Err.Number = 1004 Then
Application.ActivePrinter = "hp c Laserjet 4550N PCL6 on Ne02:"
Err.Clear
End If
Sheets("Letter").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Cover").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Agreement").Select
Dim WD As Object
Set WD = CreateObject("Word.Application")
WD.Documents.Open ("G:\CONTRACT\Contract Terms\macro\macro Jun08_04
Warranty&Maintenance Ts&Cs.C.3 Jun2004 FINAL.doc")
WD.ActiveDocument.PrintOut
WD.Application.Quit SaveChanges:=wdDoNotSaveChanges
Set WD = Nothing
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Agreement").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Cover").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Agreement").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Need VBA help


Hi Brad,

1. Is the path of the word document correct? The last folder name
appears to be too long.

2. If it is correct then then just above ' Sheets ("Letter").Select ',
add ' On Error GoTo 0 '.
Then run the code. It will give error message. Click on Debug and find
out which line is causing the error.
Post that line.

Sharad



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Need VBA help

Sharad,

I have fixed the problem. I moved the Quit Document towards the end, it
seemed like it was exiting the doc before the printing could finish. However,
I am running into one more problem. When the macro opens the word doc, it is
now asking me to select if I want read only and 2 other options. Is there any
code that I can enter that will automatically select read only? Thanks.

"Sharad" wrote:


Hi Brad,

1. Is the path of the word document correct? The last folder name
appears to be too long.

2. If it is correct then then just above ' Sheets ("Letter").Select ',
add ' On Error GoTo 0 '.
Then run the code. It will give error message. Click on Debug and find
out which line is causing the error.
Post that line.

Sharad



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Need VBA help

I started up word and opened a file readonly and recorded a macro when I did it.

I got this bit of code:

Documents.Open FileName:="Doc2.doc", ConfirmConversions:=False, ReadOnly:= _
True, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="" _
, Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto

So I bet this would work for you:

WD.Documents.Open "G:\CONTRACT\Contract Terms\macro\" _
& "macro Jun08_04 Warranty&Maintenance Ts&Cs.C.3 Jun2004 FINAL.doc", _
readonly:=true

(well, if I got the spacing correct in your filename!)

========
I've turned off MSWord's printing in the background.

It may make it easier for your process, too:

Inside MSWord:
Tools|Options|Print tab|Uncheck background printing.



Brad wrote:

Sharad,

I have fixed the problem. I moved the Quit Document towards the end, it
seemed like it was exiting the doc before the printing could finish. However,
I am running into one more problem. When the macro opens the word doc, it is
now asking me to select if I want read only and 2 other options. Is there any
code that I can enter that will automatically select read only? Thanks.

"Sharad" wrote:


Hi Brad,

1. Is the path of the word document correct? The last folder name
appears to be too long.

2. If it is correct then then just above ' Sheets ("Letter").Select ',
add ' On Error GoTo 0 '.
Then run the code. It will give error message. Click on Debug and find
out which line is causing the error.
Post that line.

Sharad



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"