![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
How can I can capture (replicate programatically) the act of copying
the body of a Word document to an Outlook message? Thanks. |
#2
|
|||
|
|||
![]()
Those are 2 different things. Which do you want to do, trap when a copy from
Word is made to an Outlook item body, or copy text from Word to an Outlook item body using code? -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Namgaw" wrote in message ... How can I can capture (replicate programatically) the act of copying the body of a Word document to an Outlook message? Thanks. |
#3
|
|||
|
|||
![]()
On 6 Dec, 10:13, "Ken Slovak - [MVP - Outlook]"
wrote: Those are 2 different things. Which do you want to do, trap when a copy from Word is made to an Outlook item body, or copy text from Word to an Outlook item body using code? -- Ken Slovak [MVP - Outlook]http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm "Namgaw" wrote in message ... How can I can capture (replicate programatically) the act of copying the body of a Word document to an Outlook message? Thanks.- Hide quoted text - - Show quoted text - The latter, i.e. copy text from Word to an Outlook item body using code. I save the file to filtered HTML. Here is the code: Sub SendDocumentInMail() Dim bStarted As Boolean Dim oOutlookApp As Outlook.Application Dim oItem As Outlook.MailItem Dim myDoc As Document Dim fileName As String 'On Error Resume Next ActiveDocument.Bookmarks("stock_code_V").Select fileName = Selection.Range fileName = getString(fileName) ActiveDocument.SaveAs fileName:="H:\Diana\email macros\email tmp\" & fileName, _ FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _ AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _ :=False, SaveAsAOCELetter:=False 'wdformatfilteredhtml 'ActiveDocument.SaveAs fileName:="H:\Diana\email macros\email tmp\" & fileName, _ FileFormat:=wdFormatRTF, LockComments:=False, Password:="", _ AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _ :=False, SaveAsAOCELetter:=False Selection.WholeStory 'Get Outlook if it's running Set oOutlookApp = GetObject(, "Outlook.Application") If Err 0 Then 'Outlook wasn't running, start it from code Set oOutlookApp = CreateObject("Outlook.Application") bStarted = True End If 'Create a new mailitem Set oItem = oOutlookApp.CreateItem(olMailItem) ActiveDocument.Bookmarks("stock_code_V").Select Dim fso As FileSystemObject Set fso = CreateObject("Scripting.FileSystemObject") Dim ts As TextStream Set ts = fso.OpenTextFile("H:\Diana\email macros\email tmp\" & fileName & ".doc", _ ForReading) strtext = ts.ReadAll With oItem 'Set the recipient for the new email .To = " 'Set the recipient for a copy .CC = " 'Set the subject .Subject = "FPKCCW: " & Selection.Range & " - Title" 'The content of the document is used as the body for the email ' Selection.WholeStory ' Selection.Copy Selection.WholeStory .Body = strtext ' .HTMLBody = strtext ' .HTMLBody = Selection.Range .Send End With If bStarted Then 'If we started Outlook from code, then close it oOutlookApp.Quit End If 'Clean up Set oItem = Nothing Set oOutlookApp = Nothing End Sub Private Function getString(ByVal Stringin As String) As String If InStr(1, Stringin, "/") 0 Then getString = Replace(Stringin, "/", "") End If End Function What happens is that the mail comes in with everything but the tables, graphics. |
#4
|
|||
|
|||
![]()
See if it works any better if you just get the entire contents of the Word
doc as a string and set Body to that. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Namgaw" wrote in message ... snip The latter, i.e. copy text from Word to an Outlook item body using code. I save the file to filtered HTML. Here is the code: Sub SendDocumentInMail() Dim bStarted As Boolean Dim oOutlookApp As Outlook.Application Dim oItem As Outlook.MailItem Dim myDoc As Document Dim fileName As String 'On Error Resume Next ActiveDocument.Bookmarks("stock_code_V").Select fileName = Selection.Range fileName = getString(fileName) ActiveDocument.SaveAs fileName:="H:\Diana\email macros\email tmp\" & fileName, _ FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _ AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _ :=False, SaveAsAOCELetter:=False 'wdformatfilteredhtml 'ActiveDocument.SaveAs fileName:="H:\Diana\email macros\email tmp\" & fileName, _ FileFormat:=wdFormatRTF, LockComments:=False, Password:="", _ AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _ :=False, SaveAsAOCELetter:=False Selection.WholeStory 'Get Outlook if it's running Set oOutlookApp = GetObject(, "Outlook.Application") If Err 0 Then 'Outlook wasn't running, start it from code Set oOutlookApp = CreateObject("Outlook.Application") bStarted = True End If 'Create a new mailitem Set oItem = oOutlookApp.CreateItem(olMailItem) ActiveDocument.Bookmarks("stock_code_V").Select Dim fso As FileSystemObject Set fso = CreateObject("Scripting.FileSystemObject") Dim ts As TextStream Set ts = fso.OpenTextFile("H:\Diana\email macros\email tmp\" & fileName & ".doc", _ ForReading) strtext = ts.ReadAll With oItem 'Set the recipient for the new email .To = " 'Set the recipient for a copy .CC = " 'Set the subject .Subject = "FPKCCW: " & Selection.Range & " - Title" 'The content of the document is used as the body for the email ' Selection.WholeStory ' Selection.Copy Selection.WholeStory .Body = strtext ' .HTMLBody = strtext ' .HTMLBody = Selection.Range .Send End With If bStarted Then 'If we started Outlook from code, then close it oOutlookApp.Quit End If 'Clean up Set oItem = Nothing Set oOutlookApp = Nothing End Sub Private Function getString(ByVal Stringin As String) As String If InStr(1, Stringin, "/") 0 Then getString = Replace(Stringin, "/", "") End If End Function What happens is that the mail comes in with everything but the tables, graphics. |
#5
|
|||
|
|||
![]()
On 6 Dec, 16:11, "Ken Slovak - [MVP - Outlook]"
wrote: See if it works any better if you just get the entire contents of the Word doc as a string and set Body to that. -- Ken Slovak [MVP - Outlook]http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm "Namgaw" wrote in message ... snip The latter, i.e. copy text from Word to an Outlook item body using code. I save the file to filtered HTML. Here is the code: Sub SendDocumentInMail() Dim bStarted As Boolean Dim oOutlookApp As Outlook.Application Dim oItem As Outlook.MailItem Dim myDoc As Document Dim fileName As String 'On Error Resume Next ActiveDocument.Bookmarks("stock_code_V").Select fileName = Selection.Range fileName = getString(fileName) ActiveDocument.SaveAs fileName:="H:\Diana\email macros\email tmp\" & fileName, _ FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _ AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _ :=False, SaveAsAOCELetter:=False 'wdformatfilteredhtml 'ActiveDocument.SaveAs fileName:="H:\Diana\email macros\email tmp\" & fileName, _ FileFormat:=wdFormatRTF, LockComments:=False, Password:="", _ AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _ :=False, SaveAsAOCELetter:=False Selection.WholeStory 'Get Outlook if it's running Set oOutlookApp = GetObject(, "Outlook.Application") If Err 0 Then 'Outlook wasn't running, start it from code Set oOutlookApp = CreateObject("Outlook.Application") bStarted = True End If 'Create a new mailitem Set oItem = oOutlookApp.CreateItem(olMailItem) ActiveDocument.Bookmarks("stock_code_V").Select Dim fso As FileSystemObject Set fso = CreateObject("Scripting.FileSystemObject") Dim ts As TextStream Set ts = fso.OpenTextFile("H:\Diana\email macros\email tmp\" & fileName & ".doc", _ ForReading) strtext = ts.ReadAll With oItem 'Set the recipient for the new email .To = " 'Set the recipient for a copy .CC = " 'Set the subject .Subject = "FPKCCW: " & Selection.Range & " - Title" 'The content of the document is used as the body for the email ' Selection.WholeStory ' Selection.Copy Selection.WholeStory .Body = strtext ' .HTMLBody = strtext ' .HTMLBody = Selection.Range .Send End With If bStarted Then 'If we started Outlook from code, then close it oOutlookApp.Quit End If 'Clean up Set oItem = Nothing Set oOutlookApp = Nothing End Sub Private Function getString(ByVal Stringin As String) As String If InStr(1, Stringin, "/") 0 Then getString = Replace(Stringin, "/", "") End If End Function What happens is that the mail comes in with everything but the tables, graphics.- Hide quoted text - - Show quoted text - No luck on that. Any other suggestions? |
#6
|
|||
|
|||
![]()
Then I think the only way to do what you want would be to work in HTML and
set the text from Word into HTMLBody using the HTML tags and HTML code and parsing. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Namgaw" wrote in message ... snip No luck on that. Any other suggestions? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Pasting from Word 2002 to Outlook 2003 | Namgaw | Outlook - General Queries | 1 | December 6th 07 08:07 AM |
Merging Outlook 2003 with Word 2002 | Sandy Sanders | Outlook - General Queries | 1 | May 13th 07 04:02 AM |
Using Outlook 2002 contacts with Word 2003 | Achez | Outlook - Using Contacts | 1 | December 20th 06 11:26 PM |
Problem in pasting URL from MS Word | Baha | Outlook - Installation | 8 | December 10th 06 11:38 PM |
Outlook 2003 + Word 2002 | Cam474 | Add-ins for Outlook | 1 | July 5th 06 02:09 AM |