Outlook dropping an image

N

Nick Ward

Hi
I have a function that generates a customer quotation in MS Word. It also
inserts a picture of my choosing into a bookmark in the word template:

If Not IsNull(Forms!frm_quote![SuggestedImage]) Then
m_objWord.ActiveDocument.Bookmarks("picy").Select
m_objWord.Selection.InlineShapes.AddPicture FileName:= _
recSupps("suggestedImage") _
, LinkToFile:=False, SaveWithDocument:=True
End If

This all work swimmingly well except that I have encountered a problem when
I have some code that generates a quote and then attaches it to an email.
Its attaching the word doc without the image! so I get the quote generated
missing the jpg.

Was wondering if anyone has come across this before as its really annoying
as I have to manually attach the quote to the email to get over this problem

strOrder = "Dear " & recSupps("Salutation") & _
vbCrLf & vbCrLf & _
"Many thanks for your enquiry please find your quote attached
to this email." & _
vbCrLf & vbCrLf & _
"Kind Regards" & _
vbCrLf & vbCrLf & _
"Nick Ward"

If Not IsNull(recSupps("Email")) Then
Set objMessage = objOutlook.CreateItem(olMailItem)
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myInbox.Items
Set mydestfolder = myInbox.Folders("quotes to be sent")

With objMessage

.BodyFormat = olFormatRichText
.Importance = olImportanceHigh
.To = recSupps("Email")
.Subject = "Requested Quote"
.Body = strOrder
.Attachments.Add M_strDIRSave & m_objDoc
.Save
.Move mydestfolder
End With
End If
m_objDoc.Close
m_objWord.Quit
Set m_objDoc = Nothing
Set m_objWord = Nothing
requerynotesform
 
N

Nick Ward

Problem Solved....
If you close the word object first and then attach it , it works ok

so
dim myattach as string
myattach = m_objdoc

m_objDoc.Close
m_objWord.Quit
Set m_objDoc = Nothing
Set m_objWord = Nothing

.BodyFormat = olFormatRichText
.Importance = olImportanceHigh
.To = recSupps("Email")
.Subject = "Requested Quote"
.Body = strOrder
.Attachments.Add M_strDIRSave & myattach
.Save
.Move mydestfolder
 
L

Larry Linson

I'm glad you found the answer. But, wouldn't a newsgroup dedicated to either
Outlook or Word have been a better place to ask than one dedicated to
Microsoft Access database questions and answers?

Larry Linson
Microsoft Access MVP

Nick Ward said:
Problem Solved....
If you close the word object first and then attach it , it works ok

so
dim myattach as string
myattach = m_objdoc

m_objDoc.Close
m_objWord.Quit
Set m_objDoc = Nothing
Set m_objWord = Nothing

.BodyFormat = olFormatRichText
.Importance = olImportanceHigh
.To = recSupps("Email")
.Subject = "Requested Quote"
.Body = strOrder
.Attachments.Add M_strDIRSave & myattach
.Save
.Move mydestfolder



Nick Ward said:
Hi
I have a function that generates a customer quotation in MS Word. It also
inserts a picture of my choosing into a bookmark in the word template:

If Not IsNull(Forms!frm_quote![SuggestedImage]) Then
m_objWord.ActiveDocument.Bookmarks("picy").Select
m_objWord.Selection.InlineShapes.AddPicture FileName:= _
recSupps("suggestedImage") _
, LinkToFile:=False, SaveWithDocument:=True
End If

This all work swimmingly well except that I have encountered a problem when
I have some code that generates a quote and then attaches it to an email.
Its attaching the word doc without the image! so I get the quote generated
missing the jpg.

Was wondering if anyone has come across this before as its really annoying
as I have to manually attach the quote to the email to get over this problem

strOrder = "Dear " & recSupps("Salutation") & _
vbCrLf & vbCrLf & _
"Many thanks for your enquiry please find your quote attached
to this email." & _
vbCrLf & vbCrLf & _
"Kind Regards" & _
vbCrLf & vbCrLf & _
"Nick Ward"

If Not IsNull(recSupps("Email")) Then
Set objMessage = objOutlook.CreateItem(olMailItem)
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myInbox.Items
Set mydestfolder = myInbox.Folders("quotes to be sent")

With objMessage

.BodyFormat = olFormatRichText
.Importance = olImportanceHigh
.To = recSupps("Email")
.Subject = "Requested Quote"
.Body = strOrder
.Attachments.Add M_strDIRSave & m_objDoc
.Save
.Move mydestfolder
End With
End If
m_objDoc.Close
m_objWord.Quit
Set m_objDoc = Nothing
Set m_objWord = Nothing
requerynotesform
 
Top