C
Carol G
I am creating the word object from Outlook.
I wish to create an envelope Only
I don't know much about the Word object. This sub creates both a document
and the envelope.
Is there any way to create only the envelope?
Thanks
Carol
Sub SingleEnvelopefromContact()
Dim objOutlook As Outlook.Application
Dim ins As Inspector
Dim itm As ContactItem
Dim objWord As Word.Application
Dim objDocs As Word.Documents
Dim addr As String
Set objOutlook = CreateObject("Outlook.Application")
Set ins = objOutlook.ActiveInspector
Set itm = ins.CurrentItem
Debug.Print "Selected item " & ins.Caption
Debug.Print "Item class: " & itm.Class
If itm.Class <> olContact Then
MsgBox "The active Inspector is not a contact item; exiting"
Exit Sub
End If
'Open Word invisibly
Set objWord = CreateObject("Word.Application")
On Error GoTo errhandler
addr = objWord.ActiveDocument.Envelope.Address.Text
errhandler:
'If Err = 5852 Then MsgBox "Add an envelope to the document
'This example creates a new document and adds an envelope with a predefined
delivery address and return address.
addr = itm.FullName & vbCr & itm.HomeAddress
retaddr = "Grant Geddes" & vbCr & "Sutton Group Canwest " _
& vbCrLf & "242, 755 Lk. Bonavista Dr. S.E." _
& vbCr & "Calgary, AB T2J 0N3"
objWord.Documents.Add.Envelope.Insert Address:=addr, ReturnAddress:=retaddr
'objWord.ActiveDocument.ActiveWindow.View.Type = wdPrintView
objWord.Visible = True
End Sub
I wish to create an envelope Only
I don't know much about the Word object. This sub creates both a document
and the envelope.
Is there any way to create only the envelope?
Thanks
Carol
Sub SingleEnvelopefromContact()
Dim objOutlook As Outlook.Application
Dim ins As Inspector
Dim itm As ContactItem
Dim objWord As Word.Application
Dim objDocs As Word.Documents
Dim addr As String
Set objOutlook = CreateObject("Outlook.Application")
Set ins = objOutlook.ActiveInspector
Set itm = ins.CurrentItem
Debug.Print "Selected item " & ins.Caption
Debug.Print "Item class: " & itm.Class
If itm.Class <> olContact Then
MsgBox "The active Inspector is not a contact item; exiting"
Exit Sub
End If
'Open Word invisibly
Set objWord = CreateObject("Word.Application")
On Error GoTo errhandler
addr = objWord.ActiveDocument.Envelope.Address.Text
errhandler:
'If Err = 5852 Then MsgBox "Add an envelope to the document
'This example creates a new document and adds an envelope with a predefined
delivery address and return address.
addr = itm.FullName & vbCr & itm.HomeAddress
retaddr = "Grant Geddes" & vbCr & "Sutton Group Canwest " _
& vbCrLf & "242, 755 Lk. Bonavista Dr. S.E." _
& vbCr & "Calgary, AB T2J 0N3"
objWord.Documents.Add.Envelope.Insert Address:=addr, ReturnAddress:=retaddr
'objWord.ActiveDocument.ActiveWindow.View.Type = wdPrintView
objWord.Visible = True
End Sub