Command Button

Herms

New Member
Joined
Apr 7, 2019
Messages
2
Good day.

I have 4 forms on one worksheet.

I need to place a command button with each form.
On click the relevant form needs to be saved as pdf on desktop.

Please advice
Regards and thank you in advance
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,810
Office Version
2007
Platform
Windows
Try this.
Change data in red by your information.

Code:
Sub Button1()
    Range("[COLOR=#ff0000]A1:C6[/COLOR]").ExportAsFixedFormat Type:=xlTypePDF, Filename:=Environ("USERPROFILE") & "\Desktop\" & "[COLOR=#ff0000]file1[/COLOR].pdf"
End Sub


Sub Button2()
    Range("[COLOR=#ff0000]D1:F6[/COLOR]").ExportAsFixedFormat Type:=xlTypePDF, Filename:=Environ("USERPROFILE") & "\Desktop\" & "[COLOR=#ff0000]file2[/COLOR].pdf"
End Sub


Sub Button3()
    Range("[COLOR=#ff0000]G1:I6[/COLOR]").ExportAsFixedFormat Type:=xlTypePDF, Filename:=Environ("USERPROFILE") & "\Desktop\" & "[COLOR=#ff0000]file3[/COLOR].pdf"
End Sub


Sub Button4()
    Range([COLOR=#ff0000]"J1:L6[/COLOR]").ExportAsFixedFormat Type:=xlTypePDF, Filename:=Environ("USERPROFILE") & "\Desktop\" & "[COLOR=#ff0000]file4[/COLOR].pdf"
End Sub
 

Forum statistics

Threads
1,077,991
Messages
5,337,591
Members
399,156
Latest member
RaudMees

Some videos you may like

This Week's Hot Topics

Top