Word - Outlook 2007 using com-objects Active X

raf.pauwels

New Member
Hello,

Can someone help me with the following :

I want to open a file in word, copy the content into the body of a new e-mail using com-objects.

Thanks advance.
 

RealHeavyDude

Well-Known Member
You don't say anything 'bout your Progress/OpenEdge version ...

The samples ( which you find in the %DLC%\src\samples folder ) contain an example using the word spell checker. You can go from there on ...

IMHO, the challenge then is to know the APIs which are provided by Microsoft.

HTH, RealHeavyDude.
 

raf.pauwels

New Member
Hi,

I'm working with openedge version 10.2A

I find some code on the internet that does almost the same but than from Excel

'--------------------------- start code ----------------------------------
Sub opgemaakte_mails_versturen()
'# - Macro getest met Office 2003
'# - Let op voor gebruik de volgende zaken controleren
'# Outlook openen -> extra -> tabblad E-mailindeling ->
'# microsoft office 2003 gebruiken voor het bewerken van e-mailberichten
'# - verwijzing instellen naar Microsoft Outlook Object library
'# - verwijzing instellen naar Microsoft Word Object library

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objInspector As Outlook.Inspector
Dim appWord As Word.Application
Dim myDestFolder As Outlook.MAPIFolder
Dim bereik, cel
Dim objDoc As Word.Document
Dim sFilename$

'# word document dat in de body van de email moet worden geplaatst
sFilename = "c:\testmail.doc"

'# Controleren of word is ingesteld als email-editor,
'# als dit zo is niks aan de hand anders wordt de macro beeindigd
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
objOutlookMsg.Display
Set objInspector = objOutlook.ActiveInspector
If objInspector.EditorType <> olEditorWord Then
MsgBox "Let op:" & Chr(10) & "voor gebruik van deze macro is het
nodig dat wordt als emaileditor is ingesteld, dit doe je als volgt:" & _
Chr(10) & "In Outlook naar extra -> tabblad E-mailindeling ->
vink aan: ""microsoft office 2003 gebruiken voor het bewerken van
e-mailberichten""" & Chr(10) & _
"De macro wordt nu afgesloten", vbInformation

objOutlookMsg.Close olDiscard
Set objOutlookMsg = Nothing
Set objInspector = Nothing
Set objOutlook = Nothing
End
Else
objOutlookMsg.Close olDiscard
End If

'# wordsessie starten en bestand openen dat in de body van de email moet
komen
Set appWord = New Word.Application
appWord.Visible = True

Set objDoc = appWord.Documents.Open(sFilename)

objDoc.Content.Copy

Set bereik = Range("Adressen")
For Each cel In bereik
If cel.Column = 1 Then
'# emailtje aanmaken
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
'# instellingen doorvoeren voor de net aangemaakte email
With objOutlookMsg
.Subject = "uitnodiging"
.BodyFormat = olFormatHTML
.Display
.To = cel.Offset(0, 1)
End With

'# plakken van het gekopieerde worddocument
Set objInspector = objOutlook.ActiveInspector
Set objDoc = objInspector.WordEditor
objDoc.Range.Paste
'# opslaan als concept
'objOutlookMsg.Move
objOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderDrafts)
'# versturen
objOutlookMsg.Send
End If

Next cel
'# sluiten van word
appWord.Quit

Set objDoc = Nothing
Set appWord = Nothing
Set objOutlookMsg = Nothing
Set objInspector = Nothing
Set objOutlook = Nothing

End Sub


I want some help to translate the part of the COPY/PASTE but than from Word to the body of a new e-mail.

Thanks in advance.
 
Top