Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Jay,
Please refer to this macro you gave me: First, understand that _all_ code must be between a line that starts with "Sub" and a line that says "End Sub". If you try to stick some code before the first Sub line, you'll just get a syntax error. Second, you've now achieved a mishmash of bits and pieces that wouldn't work together even if you got them in the right places. The sequence of events you want, if I understand correctly what's in the templates "MoJR Packet.dot" and "packet envelope.dot", is this: 1. Create a new document based on "MoJR Packet.dot" -- _not_ through a macro, but by clicking File New and choosing that template. This new document is a protected form that includes the fields pnm1 and padd1 through padd3. You manually enter name and address information in these fields. If you want to keep a copy of the letter, you manually save the document and give it a file name. 2. Press a key combination or click a toolbar button to run the MakeEnvelope macro, which is stored in a module in the "MoJR Packet.dot" template. 3. The macro mimics using the Envelope dialog and clicking the Add to Document button to insert an envelope as page 0. Then it prints the entire document, including the envelope and multiple copies of several pages. The document should then be closed without being saved, so the stored file doesn't include the envelope. 4. The macro creates a new document based on "packet envelope.dot" which is a return envelope, prints it, and closes it without saving. The macro that does steps 3 and 4 should look like this: Sub MakeEnvelope() Dim addr As String addr = _ ActiveDocument.FormFields("pnm1").Result & vbCr & _ ActiveDocument.FormFields("padd1").Result ActiveDocument.FormFields("padd2").Result ActiveDocument.FormFields("padd3").Result If ActiveDocument.ProtectionType wdNoProtection Then ActiveDocument.Unprotect End If With Dialogs(wdDialogToolsEnvelopesAndLabels) .DefaultTab = _ wdDialogToolsEnvelopesAndLabelsTabEnvelopes .EnvReturn = Application.UserAddress .AddrText = addr .Execute End With ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _ NoReset:=True With Dialogs(wdDialogFilePrint) .Background = False .Range = wdPrintRangeOfPages .Pages = "0,1,2,2,3,3,3,4,4,4,5" .Execute End With ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges Documents.Add Template:= _ "C:\Documents and Settings\MoJR\Application Data" _ & "\Microsoft\Templates\JR\packet envelope.dot", _ NewTemplate:=False, DocumentType:=0 ActiveDocument.PrintOut Background:=False ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges End Sub I am having trouble with this line; ActiveDocument.FormFields("padd2").Result I get a compile error, incorrect use of property. Please check this out and get back to me. Thank you mojr |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can I print an envelope without unlocking my document? Slight retu | Microsoft Word Help | |||
MS Word should let me print an envelope from MS Outlook in fewer . | Microsoft Word Help | |||
Print What... Document Showing Markup | Microsoft Word Help | |||
during print preview legal size document cuts to letter size | Microsoft Word Help | |||
Section of a Word Document Fails to Print and Drops Out of Attachm | Microsoft Word Help |