Convert Excel To PDF

  • Is it possible to convert an xls workbook to pdf and save it within a beforesave sub. I have managed to cobble together a piece of code that saves using cell values as the filename, but I also need another copy saved as a pdf. I am using excel 2004 on a mac. As you can save file as pdf manually with File_Print_Save as PDF I thought it would be easy. Perhaps I need a later copy of excel. If anyone can help I would be very grateful.

  • Re: Convert Excel To PDF


    Hi,

    according to me the code uses a "printer" to convert the file to a pdf.
    It's the same as on my computer. We can convert word, excel, ... to pdf by just using a printer "pdf" that converts and saves the file to a pdf-file.

    Unless you have this software active the code won't work. Check if you have in your printer list a pdfcreator or something like that.

  • Re: Convert Excel To PDF


    Hi Gollem


    I dont think I do have any software apart from the in built mac stuff. What could I download that would help? I do have adobe reader but thats about it.

  • Re: Convert Excel To PDF


    I have downloaded jaws pdf creator, but the above code still doesnt work. The first three paragraphs show red in the vd editor.

  • Re: Convert Excel To PDF


    Hi,

    try to record a macro with the basic action.
    File-print-print to pdf-etc... Then test the macro, this should be your basic code to start.

  • Re: Convert Excel To PDF


    I have recorded a macro of the process, but it only shows this code:


    ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1
    ActiveWindow.SelectedSheets.PrintOut Copies:=1


    which is file_print but missing the save as pdf.
    The macro does work, but if I save and reopen the workbook it no longer works.

  • Re: Convert Excel To PDF


    Hi,

    it depends on the software I think. My code is:

    Code
    Application.ActivePrinter = "PDFCreator on 00:"
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
            "PDFCreator on 00:", Collate:=True



    I use pdfcreator to convert. I have to confirm the conversion. Perhaps this method isn't good for you because you want to convert the file automatically I assume(without confirmation).

  • Re: Convert Excel To PDF


    I tried the code exchanging PDFCreator with Jaws PDF Creator, but it doesnt like Application.ActivePrinter, I think this might be a Mac thing.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!