Word 2003 Macro

G

Gary

Hello folks,
I inherited a macro that does not work with a new letterhead template that
has a framed paragraph. Please let me know if there is a way to have the
macro work with the new letterhead. I am a macro novice but know how to
navigate enough to edit an existing macro. Below are the macro and the error
message:

Error is: "Run time error 4605 | This method or property is not available
because the object refers to a framed paragraph" debug is greyed out for me

Sub MakePlain()
'
' Macro recorded 6/2/2003 by bradica
'
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
Selection.PageSetup.FirstPageTray = 259
End Sub

Sub MakeLetterhead()
'
' Macro recorded 6/2/2003 by bradica
'
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
Selection.PageSetup.FirstPageTray = 260
End Sub

Sub Print_withCopy()

CommandBars("Mail Merge").Visible = False
MakeLetterhead
ActiveDocument.PrintOut ' Print it ALL
MakePlain
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="1", To:="999999" '
Don't Print Envelope

End Sub
 
G

Gordon Bentley-Mix

Gary,

I'm not quite sure what you - and Word for that matter - mean by a "framed
paragraph". Is it simply a paragraph with a border around it or something
else? Without this understanding, it is difficult to determine where the
problem is. However, after a cursory examination of the code and a limited
bit of testing, I see no reason why this code should be causing any problems.
It appears to simply set the cursor to the top of the document and then
change the printer tray for the first page.

Two suggestions that may help resolve this mystery:

First, _open_ the template that contains this code prior to doing whatever
it is that you do to invoke the code. (I'm assuming that there is a toolbar
button or some such linked to the "Print_withCopy" procedure that you click
to kick everything off.) This should make it so that the Debug button is
enabled when the code fails, and you should then be able to see exactly which
line of code is causing the problem. Post back with this information and
perhaps someone will be able to assist you.

Second, try replacing the lines

Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"

with

Selection.HomeKey wdStory

This should produce the same result - moving the cursor to the top of the
document - but it's just a bit more elegant and (perhaps) less prone to error
as it has fewer arguments.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
S

SWT

The error you have is typically thrown when the framed paragraph is the very
first thing in the document/section/selection (whatever is calling the
PageSetup object). It has something to do with the PageSetup object referring
to the first character of who is calling it, and it doesn't like when it sees
an anchor to a frame/table. And don't quote me on the last sentence...

To get it to work, you would have to include any kind of character before
the frame.

Hope that helps.
 
D

Doug Robbins - Word MVP

Use the InsertBreak command. Check it out in the Word Visual Basic Help
facility

--
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, originally posted via msnews.microsoft.com
 

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