Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code for Outlook creating Fax Cover (or letter) 1

Status
Not open for further replies.

mkasson

Programmer
Jan 3, 2004
36
Tek-Tips has been very helpful to me over the last few days, so (in addition to Supporting Tek-Tips) I am enclosing below a snippet that we find useful to perhaps help the people that actually provide the answers. While you won't find this code novel or challenging, hopefully you'll find it useful as a professional.

We use Outlook extensively. While Outlook can connect to WinFax we also sometimes need a printed fax cover page under which to fax a hard copy of something. It's also sluggish and we don't love WinFax's cover pages.

I set up a new toolbar for the Contact form and put in a button titled "Fax Cover Page". That button runs this macro.

Real short and sweet: It opens a Word template fax cover page and plugs in the the currently displayed contact's info. The Word template needs to have the three bookmarks for the contact's info.

We have a similarly coded button to a open letter using our "soft" letterhead.

We intend to set up a more sophisticated macro to allow the selection of multiple recipients with an appropriately redesigned cover page.

Enjoy!
- MSK

Code:
Sub FaxCoverSheet()
Dim Wrd As Object

On Error Resume Next    ' Defer error trapping.
Set Wrd = GetObject(, "Word.Application")
If Err.Number = 429 Then
    Err.Clear
    Set Wrd = CreateObject("Word.Application")
ElseIf Err.Number <> 0 Then
    MsgBox Err.Description
    Exit Sub
End If
On Error GoTo 0

Wrd.Visible = True
Wrd.Documents.Add Template:=&quot;faxcover.dot&quot;, NewTemplate:=False
Wrd.activedocument.bookmarks(&quot;PersonName&quot;).Range.Text = Me.Inspectors.Item(1).CurrentItem.FullName
Wrd.activedocument.bookmarks(&quot;FaxNum&quot;).Range.Text = Me.Inspectors.Item(1).CurrentItem.BusinessFaxNumber
Wrd.activedocument.bookmarks(&quot;CompanyName&quot;).Range.Text = Me.Inspectors.Item(1).CurrentItem.CompanyName

End Sub


- MSK
 
Thanks for sharing, have a star!

TomCologne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top