I have this code in a word doc:
Sub Document_Open() job = InputBox("Enter Job Number") MsgBox ("Set Windows focus on Logis, then click ALT+PRINT SCREEN, then click OK below") Selection.Paste Dim DocName As String DocName = "C:\Users\tbaker\Documents\Jobs\" & job & "\" & job & ".pdf" ActiveDocument.SaveAs2 FileName:=DocName, FileFormat:=wdFormatPDF ActiveDocument.Saved = True temp = "C:\Users\tbaker\Documents\Jobs\" & job & "\" & job & ".pdf" 'fold = "C:\Users\tbaker\Documents\Jobs\" & job Dim objOutl Set objOutl = CreateObject("Outlook.Application") Set objMailItem = objOutl.CreateItem(olMailItem) Application.ScreenUpdating = False 'ans = MsgBox("Do you need to add any more attachments?", vbYesNo) 'If ans = vbYes Then ' AttachFileName = Application.GetOpenFilename("Files (*.**)," & _ ' "*.**", 1, "Select File", "Open", True) strEmailAddr = "[EMAIL="[email protected]"][email protected][/EMAIL]" objMailItem.Recipients.Add strEmailAddr objMailItem.Body = "" objMailItem.Subject = "" objMailItem.Attachments.Add temp 'For a = LBound(AttachFileName) To UBound(AttachFileName) ' objMailItem.Attachments.Add AttachFileName(a) ' Next objMailItem.Send 'End If Set objMailItem = Nothing Set objOutl = Nothing Application.ScreenUpdating = True Application.Quit End Sub
It was partly written for excel but I have moved to word as it is required.
The next question I have is how can I have the VBA code attach all the files that are present in the "fold" folder in the code (which is inactive at the moment). There could be multiple files of different types and names in this folder.
Also the inactive parts reguarding the ans = MsgBox etc this in excel gave the user the option to select multiple extra files to attach, however the "Application.GetOpenFilename" does not work in Word, would someone be able to rewrite this for word?
Thanks in advance.