J
Joop
Hi all
In an application I develope I want to send a word document via Outlook. So
I want to use MsoEnvelope to do that. I use the folowing code to accomplishe
that:
Private Sub CmdVerzEMail_Click()
Dim cn As ADODB.Connection
Dim rcdCor As New ADODB.Recordset
Dim SQLString As String
Dim DocPadString As String
Dim WApp As Object, OApp As Object
Set OApp = StartOutlook
Set cn = CurrentProject.Connection
SQLString = "SELECT * FROM TblCorres WHERE FldCorresID = " &
Me!TxtCorresID & ";"
rcdCor.Open SQLString, cn, adOpenKeyset, adLockOptimistic
DocPadString = rcdCor!FldCorresDir & rcdCor!FldCorresNaam & ".DOC"
Set WApp = StartWord
WApp.Documents.Open filename:=DocPadString
With WApp.ActiveDocument.MailEnvelope.Item
.To = "(e-mail address removed)"
.Subject = rcdCor!FldCorresOnderw
.send
End With
OApp.Application.Quit
WApp.Application.Quit wdDoNotSaveChanges
End Sub
StartOutlook and StartWord are functions that check if the application
already runs and if not it starts the application.
My question: Often when I run the code the Word document is not ready so the
"WApp.ActiveDocument.MailEnvelope.Item" generates an error (Object variable
or with block var not set). I think it is an timing problem. When I run the
code in debug mode it executes ok. How can I check if the objectproperties I
want to change are available??
thxx
Joop Aarts
In an application I develope I want to send a word document via Outlook. So
I want to use MsoEnvelope to do that. I use the folowing code to accomplishe
that:
Private Sub CmdVerzEMail_Click()
Dim cn As ADODB.Connection
Dim rcdCor As New ADODB.Recordset
Dim SQLString As String
Dim DocPadString As String
Dim WApp As Object, OApp As Object
Set OApp = StartOutlook
Set cn = CurrentProject.Connection
SQLString = "SELECT * FROM TblCorres WHERE FldCorresID = " &
Me!TxtCorresID & ";"
rcdCor.Open SQLString, cn, adOpenKeyset, adLockOptimistic
DocPadString = rcdCor!FldCorresDir & rcdCor!FldCorresNaam & ".DOC"
Set WApp = StartWord
WApp.Documents.Open filename:=DocPadString
With WApp.ActiveDocument.MailEnvelope.Item
.To = "(e-mail address removed)"
.Subject = rcdCor!FldCorresOnderw
.send
End With
OApp.Application.Quit
WApp.Application.Quit wdDoNotSaveChanges
End Sub
StartOutlook and StartWord are functions that check if the application
already runs and if not it starts the application.
My question: Often when I run the code the Word document is not ready so the
"WApp.ActiveDocument.MailEnvelope.Item" generates an error (Object variable
or with block var not set). I think it is an timing problem. When I run the
code in debug mode it executes ok. How can I check if the objectproperties I
want to change are available??
thxx
Joop Aarts