Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-22-2013, 12:37 PM
ReviTULize ReviTULize is offline Macro-enabled Template Windows 7 64bit Macro-enabled Template Office 2007
Novice
Macro-enabled Template
 
Join Date: Dec 2011
Posts: 20
ReviTULize is on a distinguished road
Default 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
Reply With Quote
 

Tags
runtime, templates



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro-enabled Template 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
Macro-enabled Template 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

Other Forums: Access Forums

All times are GMT -7. The time now is 11:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft