Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Print and update macro crashing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cheryl Cavanaugh - 07 Jan 2006 21:45 GMT
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
Doug Robbins - Word MVP - 08 Jan 2006 08:53 GMT
How did you come up with the 263 and 262?  The system obviously doesn't
recognise the 263.

See http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=101

Signature

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

>I have a template I insert into documents automatically using the
> {INCLUDETEXT .....} command.  When I press CTRL + A, F9, the template is
[quoted text clipped - 21 lines]
>
> End Sub
Cheryl Cavanaugh - 08 Jan 2006 18:31 GMT
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!

> How did you come up with the 263 and 262?  The system obviously doesn't
> recognise the 263.
[quoted text clipped - 26 lines]
> >
> > End Sub
Cheryl Cavanaugh - 08 Jan 2006 18:43 GMT
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

> 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
[quoted text clipped - 32 lines]
> > >
> > > End Sub
Doug Robbins - Word MVP - 08 Jan 2006 19:08 GMT
What happens if you do a Ctrl+A, then Ctrl+Shift+F9 (to unlink the fields)
before printing.

Signature

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

> also, I should say that this macro works perfectly fine if I'm using it on
> a
[quoted text clipped - 46 lines]
>> > >
>> > > End Sub
Cheryl Cavanaugh - 09 Jan 2006 00:55 GMT
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?

> What happens if you do a Ctrl+A, then Ctrl+Shift+F9 (to unlink the fields)
> before printing.
[quoted text clipped - 49 lines]
> >> > >
> >> > > End Sub
Doug Robbins - Word MVP - 09 Jan 2006 05:53 GMT
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.

Signature

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

>I haven't tried that.  I will.  Thanks - problem is I am not in that
>client's
[quoted text clipped - 71 lines]
>> >> > >
>> >> > > End Sub
Graham Mayor - 09 Jan 2006 07:20 GMT
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

Signature

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> 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
[quoted text clipped - 76 lines]
>>>>>>
>>>>>> End Sub
Cheryl Cavanaugh - 09 Jan 2006 15:01 GMT
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.

> If you unlink the fields they will stay unlinked, so make sure you don't
> save the changes! Or undo the changes before saving.
[quoted text clipped - 108 lines]
> >>>>>>
> >>>>>> End Sub
Cheryl Cavanaugh - 09 Feb 2006 21:51 GMT
> If you unlink the fields they will stay unlinked, so make sure you don't
> save the changes! Or undo the changes before saving.
[quoted text clipped - 108 lines]
> >>>>>>
> >>>>>> End Sub
Cheryl Cavanaugh - 09 Feb 2006 21:53 GMT
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.

> If you unlink the fields they will stay unlinked, so make sure you don't
> save the changes! Or undo the changes before saving.
[quoted text clipped - 108 lines]
> >>>>>>
> >>>>>> End Sub
Peter Jamieson - 13 Feb 2006 11:10 GMT
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

> Unlinking the fields did not work, although this problem only occurs with
> documents where updating is required.  I formerly thought it was
[quoted text clipped - 123 lines]
>> >>>>>>
>> >>>>>> End Sub

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.