totalnovice2
Registered User.
- Local time
- Today, 18:55
- Joined
- May 21, 2013
- Messages
- 36
Hi.
I have been working on a project for 3 months now and i am really close to completion but this last but is a real sticking point.
As you'll see in the code below i have the code to fill in bookmarks on word using data from my access database, the "activedocument.sendmail" line only allows me to open an instance of Outlook but no further details.
I need to be able to add code to the below to tell it that the .subject should be the information from the access fields (named below), the .body should be some predetermind text and there needs to be a pre-determined e-mail address too.
I have looked around online but i can't seem to find anything telling me exactly what to do.
Any help would be great thanks.
Private Sub cmdo2permit_Click()
On Error Resume Next
'Declare the follwing
Dim objWord As Word.Application
'Set word as an application and make it invisible
Set objWord = CreateObject("Word.Application")
objWord.Visible = False 'True is visible
'path and name of the template your are using.
objWord.Documents.Add ("C:\Users\602180742\Desktop\Auto\Access\New Access\Latest\O2Maygyrney.dotm")
'This is for the bookmark that you created in the template
objWord.ActiveDocument.Bookmarks("O2today").Select
'This is the field in access that containts the data that has to be entered at the
'bookmark
objWord.Selection.Text = Forms![Front Page]![Auto_Date]
objWord.ActiveDocument.Bookmarks("O2CS").Select
objWord.Selection.Text = Forms![Front Page]![Site 2 Name]
objWord.ActiveDocument.Bookmarks("O2CSNAME").Select
objWord.Selection.Text = Forms![Front Page]![Site 2 Owner]
objWord.ActiveDocument.Bookmarks("O2CSPOSTCODE").Select
objWord.Selection.Text = Forms![Front Page]![Postcode S2]
objWord.ActiveDocument.Bookmarks("O2ENG1").Select
objWord.Selection.Text = Forms![Front Page]![Combo79]
objWord.ActiveDocument.Bookmarks("O2ENG2").Select
objWord.Selection.Text = Forms![Front Page]![Combo81]
objWord.ActiveDocument.Bookmarks("O2ENG3").Select
objWord.Selection.Text = Forms![Front Page]![Combo83]
objWord.ActiveDocument.Bookmarks("O2ENG4").Select
objWord.Selection.Text = Forms![Front Page]![Combo93]
objWord.ActiveDocument.Bookmarks("O2ENGLEAD").Select
objWord.Selection.Text = Forms![Front Page]![Combo79]
objWord.ActiveDocument.Bookmarks("O2ENGLEADMOB").Select
objWord.Selection.Text = Forms![Front Page]![txtTelNo]
objWord.ActiveDocument.Bookmarks("O2START").Select
objWord.Selection.Text = Forms![Front Page]![Text98]
objWord.ActiveDocument.Bookmarks("O2END").Select
objWord.Selection.Text = Forms![Front Page]![Text139]
'Word (or the document that you created with the template, will now open)
objWord.Visible = True
ActiveDocument.SendMail
I have been working on a project for 3 months now and i am really close to completion but this last but is a real sticking point.
As you'll see in the code below i have the code to fill in bookmarks on word using data from my access database, the "activedocument.sendmail" line only allows me to open an instance of Outlook but no further details.
I need to be able to add code to the below to tell it that the .subject should be the information from the access fields (named below), the .body should be some predetermind text and there needs to be a pre-determined e-mail address too.
I have looked around online but i can't seem to find anything telling me exactly what to do.
Any help would be great thanks.
Code:
On Error Resume Next
'Declare the follwing
Dim objWord As Word.Application
'Set word as an application and make it invisible
Set objWord = CreateObject("Word.Application")
objWord.Visible = False 'True is visible
'path and name of the template your are using.
objWord.Documents.Add ("C:\Users\602180742\Desktop\Auto\Access\New Access\Latest\O2Maygyrney.dotm")
'This is for the bookmark that you created in the template
objWord.ActiveDocument.Bookmarks("O2today").Select
'This is the field in access that containts the data that has to be entered at the
'bookmark
objWord.Selection.Text = Forms![Front Page]![Auto_Date]
objWord.ActiveDocument.Bookmarks("O2CS").Select
objWord.Selection.Text = Forms![Front Page]![Site 2 Name]
objWord.ActiveDocument.Bookmarks("O2CSNAME").Select
objWord.Selection.Text = Forms![Front Page]![Site 2 Owner]
objWord.ActiveDocument.Bookmarks("O2CSPOSTCODE").Select
objWord.Selection.Text = Forms![Front Page]![Postcode S2]
objWord.ActiveDocument.Bookmarks("O2ENG1").Select
objWord.Selection.Text = Forms![Front Page]![Combo79]
objWord.ActiveDocument.Bookmarks("O2ENG2").Select
objWord.Selection.Text = Forms![Front Page]![Combo81]
objWord.ActiveDocument.Bookmarks("O2ENG3").Select
objWord.Selection.Text = Forms![Front Page]![Combo83]
objWord.ActiveDocument.Bookmarks("O2ENG4").Select
objWord.Selection.Text = Forms![Front Page]![Combo93]
objWord.ActiveDocument.Bookmarks("O2ENGLEAD").Select
objWord.Selection.Text = Forms![Front Page]![Combo79]
objWord.ActiveDocument.Bookmarks("O2ENGLEADMOB").Select
objWord.Selection.Text = Forms![Front Page]![txtTelNo]
objWord.ActiveDocument.Bookmarks("O2START").Select
objWord.Selection.Text = Forms![Front Page]![Text98]
objWord.ActiveDocument.Bookmarks("O2END").Select
objWord.Selection.Text = Forms![Front Page]![Text139]
'Word (or the document that you created with the template, will now open)
objWord.Visible = True
ActiveDocument.SendMail
Code: