![]() |
#1
|
|||
|
|||
![]()
Hi Guys I'm a return visitor from years back.
So consider me a noob. Especially in macro/vba world. I'm struggling with my form It's a command button that launches to save template file with original title and adds date and time in plain text format 000000_0000. Then to save a pdf file locally in the 1 folder and attach it to a email with predefined recipients and body text. Currently it's doing everything accept adding date and time it appears to be replacing itself and converting the file as it. I have tried countless times and had to resort to a foundation script many times due to messing it up royally. Code below Private Sub sendreport_Click() Dim OL As Object Dim EmailItem As Object Dim Doc As Document Dim strFileName As String Application.ScreenUpdating = False Set OL = CreateObject("Outlook.Application") Set EmailItem = OL.CreateItem(0) ' 0 = olMailItem Set Doc = ActiveDocument strFileName = Replace(Doc.FullName, ".docm", ".pdf") Doc.ExportAsFixedFormat OutputFileName:=strFileName, _ ExportFormat:=wdExportFormatPDF With EmailItem .Subject = "Security handover report, for duty completion: 00/00/00 - 0000-0000" .Body = "* SECURITY INSTRUCTION = Change date/time above in end of subject line + Add designation/name to signature area below + DELETE THIS LINE OF TEXT" & vbCrLf & _ "Dear Team Member," & vbCrLf & _ " Please find attached the Security Handover Report' for the completed duty period. " & vbCrLf & _ " TYRONE= TEST: AUTO Stationary is applied Y= EDIT VBA Remove this text & UPDATE .-TO-= Email Recipients list, Master file be kept in OneDrive with a desktop shortcut link on PC desktop. Fix to save with automated in both local store file and one attached<<< REMOVE-AMMEND THIS TEXT Before going live" .To = "tyrone@email.com.au; main@emails.com.au " .Importance = 1 ' olImportanceHigh .Attachments.Add strFileName .Display End With Application.ScreenUpdating = True Set Doc = Nothing Set EmailItem = Nothing Set OL = Nothing MsgBox "Please change the *DATE* & *SHIFT TIME* in the subject line of the email. Add your Designation/NAME to the signature in the email bottom and hit send... Word is going to save and close hit OK." ActiveDocument.Close SaveChanges:=wdSaveChanges End Sub I appreciate any help regards. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Command Button | herman777 | Excel Programming | 2 | 06-02-2019 06:45 AM |
Show table list by using chek box command and save document on sharepoint by using command button | Zhibek | Word VBA | 3 | 08-16-2018 06:19 PM |
Help with a Command Button | dkohnken | Word VBA | 5 | 03-18-2015 10:13 PM |
Command Button | knp11 | PowerPoint | 2 | 01-18-2015 01:41 PM |
![]() |
cksm4 | Word VBA | 7 | 02-27-2011 08:47 PM |