Can anyone help on a macro prob

T

tweacle

I have a macro which is shown below.

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:=""
PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True
PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0
PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
ActiveDocument.Close
Documents.Open FileName:="Doc2.doc", ConfirmConversions:=False
ReadOnly:= _
False, AddToRecentFiles:=False, PasswordDocument:=""
PasswordTemplate:= _
"", Revert:=False, WritePasswordDocument:=""
WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto
With Selection.Tables(1)
With .Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorAutomatic
End With
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = wdColorAutomatic
End With
Application.PrintOut FileName:="", Range:=wdPrintAllDocument
Item:= _
wdPrintDocumentContent, Copies:=1, Pages:=""
PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True
PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0
PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
ActiveDocument.Saved = True
ActiveDocument.Close
End Sub

The trouble is its closing the first document after its set up to prin
but dont make no changes by removing the colours when it prints the 2n
one. It then just completely freezes up and nothing happens. It say
on macro to same printer but will actually be printed to 2 seperat
printers.

Can anyone help as to why it keeps freezing. I also dont need it t
save changes when the colours removed. Can anyone help? Thank
 
C

Cindy M.

Hi Tweacle,
The trouble is its closing the first document after its set up to print
but dont make no changes by removing the colours when it prints the 2nd
one. It then just completely freezes up and nothing happens. It says
on macro to same printer but will actually be printed to 2 seperate
printers.
I'm guessing the problem could come from the fact that you're leaving
"Background printing" active. This means that the macro will continue
before the first print job has completely finished, which can always lead
to problems. Put this line at the beginning of your code

Application.Options.PrintBackground =False

and this one at the end if you want to leave the option on for the user

Application.Options.PrintBackground =True

Even better programming practice would be to get the user's setting, then
make sure you restore it at the end.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top