aushknotes
Fri Jul 11 03:28:00 PDT 2008
Thanks for you quick reply, but still the same error 91 on the statement
objDoc.Range.Paste
"Graham Mayor" wrote:
> The final working macro was
>
> Sub Send_Extract_As_EMail()
> ' send the document in an Outlook Email message
> ' 2007 Graham Mayor, Tony Jollans, Doug Robbins
> ' & Sue Mosher
>
> Dim bStarted As Boolean
> Dim oOutlookApp As Outlook.Application
> Dim oItem As Outlook.MailItem
> Dim objDoc As Word.Document
> Dim strEMail As String
>
> strEMail = "<PR_EMAIL_ADDRESS>"
> 'Let the user choose the contact from Outlook
> 'And assign the email address to a variable
>
> strEMail = Application.GetAddress("", strEMail, _
> False, 1, , , True, True)
> If strEMail = "" Then
> MsgBox "User cancelled or no address listed", , "Cancel"
> End If
>
> On Error Resume Next
>
> 'Get Outlook if it's running
> Set oOutlookApp = GetObject(, "Outlook.Application")
>
> 'Outlook wasn't running, start it from code
> If Err <> 0 Then
> Set oOutlookApp = CreateObject("Outlook.Application")
> bStarted = True
> End If
>
> 'Create a new mailitem
> Set oItem = oOutlookApp.CreateItem(olMailItem)
> Set objDoc = oItem.GetInspector.WordEditor
> With oItem
> .To = strEMail
> .Subject = InputBox("Subject?")
> Selection.Copy
> objDoc.Range.Paste
> .Display
> End With
>
> 'Clean up
> Set oItem = Nothing
> Set oOutlookApp = Nothing
> End Sub
>
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - Word MVP
>
> My web site www.gmayor.com
> Word MVP web site
http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> aushknotes wrote:
> > Hi,
> >
> > I am referring to the thread "How to get to email from Word" dated
> > 4/20/2008. Virtually you have made the formatting worked.
> >
> > I'm using Word 2003/Outlook 2003. I copied the whole sub from
> > Gramham's final version dated 04/22/2008, but I am stuck with error
> > 91 - object variable or With block not set) on the statement
> >
> > objDoc.Range.Paste.
> >
> > What do I need to do get around with the this error?
> >
> > Many thanks,
>
>
>