fill in, and e-mail to separate addresses, 2 different documents with 1 click

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.


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
 
So at what stage are you stuck? You have to just modify the code a bit, since we have no clue of what Form values you are trying to replace or any other required information, the task is entirely up to you to complete..

If you have anything in specific that you cannot get your head around, post it up, we will try to help you out.
 
Hi.

Well I am stuck on how to actually do what I said above.

I understand that I just need change a bit of the code for command_153 BUT I don't know what to do to make Command_153 complete the actions of command_152 at the same time.

Is there a simple line of code I can tag onto the end of it that says "and then complete command-152 actions" etc.

There are times when both forms need to be generated and sent to separate e-mail addresses and there are times when the form generated by command_152 needs to be sent on its own.

I don't know where to start and google searches don't help :(
 
You could change Command_152_Click to a Public procedure, and then simply call it at the end of Command_153_Click...

Code:
[COLOR=red]Public[/COLOR] Sub Command152_Click()
 
..... code for Command Button 152....
 
End Sub
 
Private Sub Command153_Click()
 
..... code for command Button 153....
 
    Call Command152_Click
 
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom