#1
|
|||
|
|||
Macro-enabled Template
The below code works great, except for one thing. Once saved as a macro-enabled template, if you press cancel on the "save as" dialog box it errors with a "runtime error 4198...Command failed". It works great when it's a m-e doc
can someone tell me what I am missing? please advise & thank you Code:
Public Sub EmailForm_Click() Dim outl As Object Dim Mail As Object Dim Msg, Style, Title, Help, Ctxt, Response, MyString Dim PDFname As String Msg = "Choose where to save this form. An email with a .pdf attachment will automatically be generated" Style = vbOKCancel + vbQuestion + vbDefaultButton2 Title = "Confirm save & email" Ctxt = 1000 Response = MsgBox(Msg, Style, Title, Help, Ctxt) If Response = vbOK Then 'ActiveDocument.Save PDFname = ActiveDocument.Path & "\" & "SonicWall Config-" & AcctName & ".pdf" ActiveDocument.ExportAsFixedFormat OutputFileName:=PDFname, ExportFormat:=wdExportFormatPDF, _ OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportAllDocument, _ Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, UseISO19005_1:=False, _ CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:=True Set outl = CreateObject("Outlook.Application") Set Mail = outl.CreateItem(0) Mail.Subject = "SonicWall Config Request- " & AcctName Mail.Body = "" Mail.Importance = olImportanceHigh Mail.To = "mtomlinson@tulsacash.com" Mail.Attachments.Add PDFname Mail.Display Else MsgBox "The document was saved, but will not be emailed" Cancel = True End If End Sub Last edited by macropod; 01-29-2013 at 09:47 PM. Reason: Added code tags & formatting |
Tags |
runtime, templates |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Saving as ( PowerPoint Macro-Enabled Slide Show )?? | delete123 | PowerPoint | 2 | 04-10-2013 05:38 AM |
Macro Disappears from Template | Andrew H | Word | 1 | 11-26-2012 10:49 PM |
Word template containing macro + hotkeys | b0x4it | Word | 4 | 05-19-2011 06:37 PM |
Macro to open template not working | Brandi | Mail Merge | 2 | 06-24-2010 09:29 AM |
Macro to determine attached template | zippyaus | Word VBA | 0 | 03-02-2010 02:05 AM |