Announcement

Collapse
No announcement yet.

Save Excel file to another folder as .PDF

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Save Excel file to another folder as .PDF



    I'll have Excel files from a folder listed on spreadsheet in column A6 & down
    Will have right click trigger in column B

    Need VBA to Save Excel file to another folder as .PDF
    Source path is in A3
    Destination path in B3
    Source full path is A3 & A in ActiveRow
    Destination full path is B3 & A in ActiveRow, but as .PDF, not Excel

    Excel in Source folder needs to be replaced with .PDF in Destination folder, i.e. don't need to keep Excel file

  • #2
    There seems to be some inconsistencies. Maybe if you attached a file I could figure it out.

    I would move the Excel files to some other folder, unless they are backup copies, until you are happy with the macro results.

    You would be creating PDF files. If the print areas were not set in each worksheet, your pdf file could contain many pages.

    Comment


    • #3
      Are you running the cod e from the workbook to be saved as pdf?
      Hope that Helps

      Roy

      New users should read the Forum Rules before posting

      For free Excel tools & articles visit my web site

      RoyUK's Web Site

      royUK's Database Form

      Where to paste code from the Forum

      About me.

      Comment


      • #4
        @royUK - running the code from another Excel workbook, which lists the Excel file names in folder path listed in my original post, those files I am looking to affect one at a time

        Comment


        • #5
          Is it a list of files? Attach a dummy workbook, the code should be quite straightforward
          Hope that Helps

          Roy

          New users should read the Forum Rules before posting

          For free Excel tools & articles visit my web site

          RoyUK's Web Site

          royUK's Database Form

          Where to paste code from the Forum

          About me.

          Comment


          • #6
            Also, are you wanting to save just a specific sheet to pdf?
            Hope that Helps

            Roy

            New users should read the Forum Rules before posting

            For free Excel tools & articles visit my web site

            RoyUK's Web Site

            royUK's Database Form

            Where to paste code from the Forum

            About me.

            Comment


            • #7
              This is a rough idea of the code

              Code:
              Option Explicit
              
              Sub SaveAsPDF()
                  Dim oWb As Workbook
                  ''///open the workbook to save
                  Set oWb = Workbooks.Open(Range("A3").Value)
                  ''/// convert active sheet to pdf
                  ActiveWorkbook.ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
                                                                 ThisWorkbook.Sheet1.Range("B3") & Application.PathSeparator & ActiveSheet.Name & ".pdf" _
                                                                 , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
                                                                                                                           :=False, OpenAfterPublish:=True
                  ''/// close the workbook without saving
                  ActiveWorkbook.Close False
                  ''/// delete the source workbook
                  Kill (ThisWorkbook.Range("A3").Value)
              End Sub
              Hope that Helps

              Roy

              New users should read the Forum Rules before posting

              For free Excel tools & articles visit my web site

              RoyUK's Web Site

              royUK's Database Form

              Where to paste code from the Forum

              About me.

              Comment


              • #8
                This is the layout
                Code is run from this FileMaster, affecting actual files in the list
                I am realizing figuring out how to convert Excel layout to .pdf may be not as straightforward as would probably be with Word
                Maybe I will learn something from it

                Just Layout 4 FileMaster.xlsx

                Comment


                • #9


                  Have you tried the code that I have posted?
                  Hope that Helps

                  Roy

                  New users should read the Forum Rules before posting

                  For free Excel tools & articles visit my web site

                  RoyUK's Web Site

                  royUK's Database Form

                  Where to paste code from the Forum

                  About me.

                  Comment

                  Working...
                  X