• 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.

Macro to create PDF and save file

Manny Singh

Member
Hi All,

Could you please check attached file, when I press the command click button, it gives a debug error. Not sure what is wrong?

Also how can I change the command click name to "Create_PDF".

I would appreciate help.

Cheers, Manny
__________________________________________________________________
Mod edit : thread moved to appropriate forum !
 

Attachments

  • Debug VBA.xlsm
    318.3 KB · Views: 4
Hi:

Your macro is alright,but you forgot the basic naming conventions for a file , a file cannot be saved with 21/10/2016 in its name instead of "Welding Report week ending 21/10/2016" give "Welding Report week ending 21102016", the macro will work.

Thanks
 
Hi Nebu,

Thanks for your help on both date formulas, works perfect.

I have got two issues now, could you please help:

(1): Attached sheet, Cell B1 - How can I change formula to read "Weekly Report week ending 21st Oct 2016".
(2): Macro is still giving debug error and highlights below is Yellow:

.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\RECEPTION\Piping Solutions\QA\Workshop Dia Inches\Weekly Reports\" & fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
 

Attachments

  • Debug VBA.xlsm
    318.7 KB · Views: 6
Hi:

Use this formula
"Welding Report week ending "& TEXT(TODAY()- (WEEKDAY(TODAY(),2)+2),"dd mmm yyyy")
in cell B1

Thanks
 
Hi Nebu,

Thanks for your help on both date formulas, works perfect.

I have got two issues now, could you please help:

(1): Attached sheet, Cell B1 - How can I change formula to read "Weekly Report week ending 21st Oct 2016".
(2): Macro is still giving debug error and highlights below is Yellow:

.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\RECEPTION\Piping Solutions\QA\Workshop Dia Inches\Weekly Reports\" & fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

First Query already answered by Nebu.

Second Query :
1. You have to save the file before publishing as pdf. Save the file before creating pdf.
2. The file name path you have given in the macro should be already available.

If you take care of the above, there will not be any debug error.
 
Back
Top