|
-
Dec 16th, 2012, 11:09 AM
#5
Thread Starter
New Member
Re: [Outlook] Add Header and Footer to Attachment, then Print
@westconn1, thank you very much. The code you provided worked perfectly. I was finally able to create the script i wanted to do ^^
That's the code for the Print function:
TEMP_PATH is a global variable containing the Path to the temp folder, where the File will be saved
Reference to "Microsoft Word __._ Object Library" is required (In my case it was 14.0)
PrintAttBox is a form I created, so the User can modify the Inputs, like the Header and the Footer
Code:
Sub PrintWithHeader(fFullPath As String)
Dim wd As Word.Application
Dim doc As Word.Document
'MsgBox (PrintAttBox.DocName.Caption)
Set wd = CreateObject("Word.Application")
Set doc = wd.documents.Open(TEMP_PATH & PrintAttBox.DocEmail.Caption & "_" & PrintAttBox.DocPos & "_" & PrintAttBox.DocName) 'where is was saved
With doc
.Sections(1).Headers(1).Range.Text = PrintAttBox.DocHeader.Text
.Sections(1).Footers(1).Range.Text = PrintAttBox.DocFooter.Text
.PrintOut
.Save 'if required
.Close
End With
MsgBox ("The Document was saved successfully: " & TEMP_PATH & PrintAttBox.DocEmail.Caption & "_" & PrintAttBox.DocPos & "_" & PrintAttBox.DocName)
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|