• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Print and save Pdf report on excel 2007

Hi Everyone,

I tried to use a simple print and save function in VBA, but obviously something is not working. Can you help me out?

What I tried to do is instead of having defined a fixed folderpath, I tried to set a variable for the folderpath and for the pdfname I did the same. So that it will change with the input of the report automatically.

Especially the pdf name I tried to link to the Cell A1.

Hopefully I can get some Inspiration.

Thank you in advance for taking your time to read through this.
 

Attachments

  • Printandsavetest.xlsm
    34.3 KB · Views: 6
Your post doesn't deliver clearly what do you wish to do!!

Check this & share more info on the same.
  • You have selected Range("A1:I69").Select where except A1 all are blank cells.
  • Following needs to be something like this..
    Activesheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    fname, Quality:=xlQualityStandard, IncludeDocProperties:= _
    True, IgnorePrintAreas:=False, OpenAfterPublish:=False
 
@Deepak: Thank you for your help, but this gives Runtime error '5' on my workbook.

@webmax: Thank you, too for your effort, but it resulted in the same error.

After all this is maybe a bit more complicated then I have thought. Is there a setting, that I forgot?

I appreciate your help and effort.
 
Hello,

I have worked a bit with the code and here is one little example that I'd like to share. This Code creates a folder with the foldername of the Cell Value in A1 and prints a pdf in this folder with the pdfname that uses the now function of excel. I thought about using the count function, so that when the program finds out that the file already exists, it will use the same name just with a serial number.

Have a nice day!
 

Attachments

  • Printandsavetest1.xlsm
    36.9 KB · Views: 2
Back
Top