DB73
Board Regular
- Joined
- Jun 7, 2022
- Messages
- 102
- Office Version
- 365
- 2021
- 2019
- 2016
- 2010
- 2007
- Platform
- Windows
- Mobile
- Web
Hi,
I want to save a file as PDF with a cmdbtn
i want the filename as set as in a cell, like cell A1
i also want the path name as a cell value/text, co i can change the path if neccecary.
pathname for now is like desktop...dont know if it matters if its a onedrive path ?
and also dont know if there should be a folder on the desktop
i have someting like this, but doesnt seems to work;
I want to save a file as PDF with a cmdbtn
i want the filename as set as in a cell, like cell A1
i also want the path name as a cell value/text, co i can change the path if neccecary.
pathname for now is like desktop...dont know if it matters if its a onedrive path ?
and also dont know if there should be a folder on the desktop
i have someting like this, but doesnt seems to work;
VBA Code:
Private Sub CommandButton2_Click()
Dim wks As Worksheet
Set wks = ActiveSheet
Dim Path As String
Path = ActivesheetRange(“D2”).Value
Dim filename As String
filename = ActiveSheet.Range(“I18”).Value
ActiveSheet.ExportAsFixedFormat Type:=TypePDF, filename:=filename
End Sub