Print and update macro crashing

  • Thread starter Cheryl Cavanaugh
  • Start date
C

Cheryl Cavanaugh

I have a template I insert into documents automatically using the
{INCLUDETEXT .....} command. When I press CTRL + A, F9, the template is
pulled in beautifully. However, when I try to use a macro to print my
document, I get a runtime error 4608 and value out of range error. When I
select "debug", this is what I get: The line ".FirstPageTray = 263" is
highlighted. What is the problem. The macro works on documents without the
IncludeText and my update fields on print in Tools/Options is off.

Application.Run ("CopyStamp.deleteCopy")
ActivePrinter = "\\LAWSERVER\Letter_Printer"

With ActiveDocument.PageSetup
.FirstPageTray = 263
.OtherPagesTray = 262
End With
Application.Dialogs(wdDialogFilePrint).Show

ActivePrinter = "\\LAWSERVER\Draft_Printer"
With ActiveDocument.PageSetup
.FirstPageTray = 0
.OtherPagesTray = 0
End With

End Sub
 
C

Cheryl Cavanaugh

actually, there IS a macro just for print and 263 works fine. But I actually
didn't put that number in there, I just recorded the macro like any simpleton
- I recorded it while choosing the trays in the print settings and that was
the number that was inserted automatically, so I'm assuming that is not the
problem, can you think of anything else? Thanks for replying!
 
C

Cheryl Cavanaugh

also, I should say that this macro works perfectly fine if I'm using it on a
document without {Inserttext......} which pulls my letterhead in on some
documents
 
D

Doug Robbins - Word MVP

What happens if you do a Ctrl+A, then Ctrl+Shift+F9 (to unlink the fields)
before printing.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

Cheryl Cavanaugh

I haven't tried that. I will. Thanks - problem is I am not in that client's
office again until next Saturday. I will try it then and post a reply to let
you know. If there is anything else you can think of I would appreciate it.
By the way, pardon my simple-mindedness but is the "unlink" then saved when
the document has been saved or is it something you must do every time you pop
the document open? Once the fields are "unlinked" is there a control to
"link" them again? or can I simply just do CTRL + A and then F9?
 
D

Doug Robbins - Word MVP

Once you unlink them, if you save the document, they will remain unlinked.
If you do not save the document of course, when you open it again, they will
still be linked.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

Graham Mayor

If you unlink the fields they will stay unlinked, so make sure you don't
save the changes! Or undo the changes before saving.
Was the included text prepared and saved with a different printer active?
Does it have section breaks in it? It might be worth setting up the
Letter_Printer driver at your location (the printer itself does not need to
be present) and use that driver when you are preparing documents for the
client.

Is the Letter_Printer always the *same* printer or does it depend on the
user on the network, as Letter_Printer is clearly a pseudonym for an actual
printer and not all printers use the same code sequence.

When the error occurs, what does the print dialog show the current printer
to be?

I wonder if adding a \*charformat field to the includetext field would
work?

Your printer swap code can be tidied a bit with

Application.Run ("CopyStamp.deleteCopy")
Dim sCurrentPrinter As String
sCurrentPrinter = ActivePrinter
ActivePrinter = "\\LAWSERVER\Letter_Printer"
With ActiveDocument.PageSetup
.FirstPageTray = 263
.OtherPagesTray = 262
End With
Application.Dialogs(wdDialogFilePrint).Show
ActivePrinter = sCurrentPrinter
End With


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Cheryl Cavanaugh

Thank you both hugely. I have learned so much from this forum and I know you
both contribute a lot. I really appreciate your efforts. THANKS!! I will
take all the advice and see what the conclusions are. I will post my
findings.
 
C

Cheryl Cavanaugh

Graham Mayor said:
If you unlink the fields they will stay unlinked, so make sure you don't
save the changes! Or undo the changes before saving.
Was the included text prepared and saved with a different printer active?
Does it have section breaks in it? It might be worth setting up the
Letter_Printer driver at your location (the printer itself does not need to
be present) and use that driver when you are preparing documents for the
client.

Is the Letter_Printer always the *same* printer or does it depend on the
user on the network, as Letter_Printer is clearly a pseudonym for an actual
printer and not all printers use the same code sequence.

When the error occurs, what does the print dialog show the current printer
to be?

I wonder if adding a \*charformat field to the includetext field would
work?

Your printer swap code can be tidied a bit with

Application.Run ("CopyStamp.deleteCopy")
Dim sCurrentPrinter As String
sCurrentPrinter = ActivePrinter
ActivePrinter = "\\LAWSERVER\Letter_Printer"
With ActiveDocument.PageSetup
.FirstPageTray = 263
.OtherPagesTray = 262
End With
Application.Dialogs(wdDialogFilePrint).Show
ActivePrinter = sCurrentPrinter
End With


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Cheryl Cavanaugh

Unlinking the fields did not work, although this problem only occurs with
documents where updating is required. I formerly thought it was {InsertText}
that was causing the problem, but it's every document I try, where the
document was prepared somewhere else. I guess that's what it is then. I
don't have the time reserve or cash reserve to duplicate the 100+ documents
for this one client, they will just have to print manually or have their
techie alter the macro they've created so it works with everything.

Thanks for your help though. I truly appreciate it.
 
P

Peter Jamieson

One other thing that may be worth trying if you have time is avoiding
changing the printer if it is already the correct one. I've encountered
similar problems switching printers when doing Fax stuff - the reasons may
be well known but not to me - perhaps the local printer driver thing that
Graham mentioned.

e.g. building on Graham's code...

Dim sCurrentPrinter As String
sCurrentPrinter = ActivePrinter
If sCurrentPrinter <> "\\LAWSERVER\Letter_Printer" Then
ActivePrinter = "\\LAWSERVER\Letter_Printer"
End If
With ActiveDocument.PageSetup
.FirstPageTray = 263
.OtherPagesTray = 262
End With
Application.Dialogs(wdDialogFilePrint).Show
ActivePrinter = sCurrentPrinter
End With
 

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

Similar Threads


Top