totalnovice2
Registered User.
- Local time
- Today, 22:39
- Joined
- May 21, 2013
- Messages
- 36
Hello.
I have been told that I say too much without saying very much so I will try to keep this short.
I currently have a setup which allows users to click one button (command152_click) which then generates a word document using info on my form then attaches and sends to a pre-determined e-mail address.
Code for this below.
What I need to know is how to click on a different button (Command153) which will then fill out the same form as Command 152 but also fill in another form, which has different info on it, and generate an e-mail to another address.
I can't just send the same attachment to both e-mail addresses as the attachments will contain different information.
I have been told that I say too much without saying very much so I will try to keep this short.
I currently have a setup which allows users to click one button (command152_click) which then generates a word document using info on my form then attaches and sends to a pre-determined e-mail address.
Code for this below.
What I need to know is how to click on a different button (Command153) which will then fill out the same form as Command 152 but also fill in another form, which has different info on it, and generate an e-mail to another address.
I can't just send the same attachment to both e-mail addresses as the attachments will contain different information.
Code:
Private Sub Command152_Click()
On Error Resume Next
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
objWord.Documents.Add("C:\Users\Public\VodPermitnewest.doc")
objWord.ActiveDocument.Bookmarks("VFCS").Select
objWord.Selection.Text = Forms![Front Page]![Site 2 Owner]
objWord.ActiveDocument.Bookmarks("VFNAME").Select
objWord.Selection.Text = Forms![Front Page]![Site 2 Name]
objWord.ActiveDocument.SaveAs FileName:="C:\Users\Public\" & Forms![Front Page]![Site 2 Name] & " " & Forms![Front Page]![Combo79] & " " & "Vod" & ".doc", FileFormat:=Word.WdSaveFormat.wdFormatDocument97
ActiveDocument.RemoveDocumentInformation wdRDITemplate
ActiveDocument.RemoveDocumentInformation wdRDIDocumentProperties
ActiveDocument.RemoveDocumentInformation wdRDIRemovePersonalInformation
objWord.ActiveDocument.Close
Call Mail_Radio_Outlook2("C:\Users\Public\" & Forms![Front Page]![Site 2 Name] & " " & Forms![Front Page]![Combo79] & " " & "Vod" & ".doc")
Set objWord = Nothing
End Sub
Function Mail_Radio_Outlook2(activedoc As String)
'Working in Office 2000-2010
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim acc_req As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Hello.<br> <br> Please Find attached request for access. <br>"
acc_req = "Vod Access request" & " " & [Forms]![Front Page]![Text98].Value & " " & Forms![Front Page]![Site 2 Name].Value
With OutMail
On Error Resume Next
.Display
.To = " customer "
.CC = ""
.Subject = acc_req
.Attachments.Add (activedoc)
.HTMLBody = strbody & "<br>" & .HTMLBody
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
MsgBox "Your E-mail has been sent.", vbInformation + vbOKOnly, "E-mail Sent"
End Function