I had this code working in Access 2007 to create emails from Outlook and populate them. THere had bee nan upgrade to 2010 and now I'm getting a run-time error 13 (type mismathc) on the line to Set NewDoc....
Any ideas? I can't figure this out.
thanks in advance
Private Sub SendEmail_Click()
Dim db As DAO.Database
Dim rsEmailList As DAO.Recordset
Dim AuditLog As DAO.Recordset
Dim path As String
Dim objWord As Object
Dim FileN As String
Dim NewDoc As Word.Document
Dim RetVal
'URL folder of Template
path = "S:\test\" & Me.Attachment & ".doc"
Set db = CurrentDb
Set rsEmailList = db.OpenRecordset("EmailList", dbOpenSnapshot)
Set AuditLog = db.OpenRecordset("AuditEmails")
With rsEmailList
Do Until rsEmailList.EOF
'if recordset is not empty
If IsNull(.Fields("Email")) = False Then
'if there is an attachment selected
If (Right(Me.Attachment, 8) = "Template" Or Right(Me.Attachment, 13) = "Questionnaire" Or Right(Me.Attachment, 8) = "Document") Then
Set objWord = CreateObject("word.application")
objWord.Visible = True
Set NewDoc = objWord.Documents.Open(path)
Any ideas? I can't figure this out.
thanks in advance
Private Sub SendEmail_Click()
Dim db As DAO.Database
Dim rsEmailList As DAO.Recordset
Dim AuditLog As DAO.Recordset
Dim path As String
Dim objWord As Object
Dim FileN As String
Dim NewDoc As Word.Document
Dim RetVal
'URL folder of Template
path = "S:\test\" & Me.Attachment & ".doc"
Set db = CurrentDb
Set rsEmailList = db.OpenRecordset("EmailList", dbOpenSnapshot)
Set AuditLog = db.OpenRecordset("AuditEmails")
With rsEmailList
Do Until rsEmailList.EOF
'if recordset is not empty
If IsNull(.Fields("Email")) = False Then
'if there is an attachment selected
If (Right(Me.Attachment, 8) = "Template" Or Right(Me.Attachment, 13) = "Questionnaire" Or Right(Me.Attachment, 8) = "Document") Then
Set objWord = CreateObject("word.application")
objWord.Visible = True
Set NewDoc = objWord.Documents.Open(path)