View Single Post
 
Old 05-06-2014, 11:24 AM
ksigcajun ksigcajun is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: May 2014
Posts: 76
ksigcajun is on a distinguished road
Default Hiding Command Buttons before PDF

Hey everyone! New to the board and looking for some help. I know this is pretty simple, but Im looking to hide a command button when a person clicks the button to PDF. I want a user to click this button, PDF their document and the button will not show on the PDF.

Here is my code and thanks for the helping a newbie!
Code:
Private Sub CommandButton111_Click() 
    Dim outl As Object 
    Dim Mail As Object 
    Dim Msg, Style, Title, Help, Ctxt, Response, MyString 
    Dim PDFname As String 
 
    Msg = "Your Document will be saved as PDF before mailing it as attachment, please agree?" 
    Style = vbOKCancel + vbQuestion + vbDefaultButton2 
    Title = "Document" 
    Ctxt = 1000 
    Response = MsgBox(Msg, Style, Title, Help, Ctxt) 
    If Response = vbOK Then 
        ActiveDocument.Save 
        PDFname = ActiveDocument.Path & "\" & "Document.pdf" 
        ActiveDocument.ExportAsFixedFormat OutputFileName:=PDFname, _
          ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, _
          OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportAllDocument, _
          Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
          CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
          BitmapMissingFonts:=True, UseISO19005_1:=False 
        Set outl = CreateObject("Outlook.Application") 
        Set Mail = outl.CreateItem(0) 
        Mail.Subject = "Document" 
        Mail.HTMLBody = "Document<br> <br> <img src='image.gif'>" 
        Mail.To = "" 
        Mail.Attachments.Add PDFname 
        Mail.Display 
    Else 
        MsgBox "You have chosen not to save PDF and your file will not be sent" 
        Cancel = True 
    End If 
End Sub

Last edited by macropod; 05-06-2014 at 04:11 PM. Reason: Added code tags & formatting
Reply With Quote