+ Reply to Thread
Results 1 to 4 of 4

Macro to record sheet PDF

  1. #1
    Registered User
    Join Date
    08-01-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2010
    Posts
    11

    Exclamation Macro to record sheet PDF

    I intend to record a macro sheet from Excel's File in PDF format. However every time that records must verify that you want to replace the existing file with the same name. Currently I have the macro is recording sheet in PDF's. but always replaces the existing file without asking if you want to replace. The macro should look for the existence of the grave than the above without asking if you want to replace.

    Regards,

    Flash_Azul

  2. #2
    Valued Forum Contributor gjlindn's Avatar
    Join Date
    08-01-2011
    Location
    Dodgeville, WI
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    369

    Re: Macro to record sheet PDF

    Hi Flash_Azul. Could you post your recorded macro? Also, which version of Excel are you using?

  3. #3
    Registered User
    Join Date
    08-01-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Macro to record sheet PDF

    Quote Originally Posted by gjlindn View Post
    Hi Flash_Azul. Could you post your recorded macro? Also, which version of Excel are you using?

    Private Sub SAVE_ORCAMENTO_PDF_Click()

    'GRAVA EM FORMATO PDF O RELATORIO + ORÇAMENTO

    'On Error GoTo ErrorHandler
    Dim i As Integer
    Dim sName As String
    Dim sOutputPath As String
    Dim n As String
    Dim o As String

    Application.DisplayAlerts = True

    n = Range("H2").Text
    o = Range("F5").Text
    r = "(rel)"

    ' Grava os ficheiros pdf para a seguinte pasta
    sOutputPath = "M:\Orcamentacao\2011\" & n & "\" + o + r + ".pdf"

    ' Converte em PDF a primeira Sheet -DADOS GERAIS-

    Debug.Print sOutputPath



    ActiveWorkbook.Sheets(1).ExportAsFixedFormat _
    Type:=xlTypePDF, filename:=sOutputPath, _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=True


    MsgBox " Ficheiro PDF -DADOS GERAIS- criado com sucesso -> M:\Orcamentacao\2011\" & n & "\" + o + r + ".pdf", vbInformation, "RELATÓRIO"

    ' Converte em PDF a segunda Sheet - ORÇAMENTO-

    ' Grava os ficheiros pdf para a seguinte pasta
    sOutputPath = "M:\Orcamentacao\2011\" & n & "\" + o + ".pdf"


    'sName = Sheets(2).Name

    Debug.Print sOutputPath

    ActiveWorkbook.Sheets(2).ExportAsFixedFormat _
    Type:=xlTypePDF, filename:=sOutputPath, _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=True

    MsgBox "Ficheiro PDF -ORÇAMENTO- criado com sucesso -> M:\Orcamentacao\2011\" & n & "\" + o + ".pdf", vbInformation, "ORÇAMENTO"

    ErrorHandler:
    End Sub

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to record sheet PDF

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1