A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Pasting from Word 2002 to Outlook 2003



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 6th 07, 02:56 PM posted to microsoft.public.outlook.program_vba
Namgaw
external usenet poster
 
Posts: 7
Default Pasting from Word 2002 to Outlook 2003

How can I can capture (replicate programatically) the act of copying
the body of a Word document to an Outlook message?

Thanks.
  #2  
Old December 6th 07, 04:13 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Pasting from Word 2002 to Outlook 2003

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  
Old December 6th 07, 09:55 PM posted to microsoft.public.outlook.program_vba
Namgaw
external usenet poster
 
Posts: 7
Default Pasting from Word 2002 to Outlook 2003

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  
Old December 6th 07, 10:11 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Pasting from Word 2002 to Outlook 2003

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  
Old December 7th 07, 02:15 PM posted to microsoft.public.outlook.program_vba
Namgaw
external usenet poster
 
Posts: 7
Default Pasting from Word 2002 to Outlook 2003

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  
Old December 7th 07, 03:39 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Pasting from Word 2002 to Outlook 2003

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 09:26 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.