Hello,
I want to make a macro for a button that is to execute the following:
1. Open dialog box so that one can manually choose a PDF file and press OK.
2. Upon pressing OK I want it to save the chosen PDF file to a specific location and give it a specific name based on a variable (the value of a text box) and keep the extension .pdf
I have no clue if I´m even near being on track here or not, but this is what I got so far after trying several things for a couple of hours:
Private Sub Avtale_Click()
Dim FileDialog As FileDialog
Dim FileDialog1 As FileDialog
Dim FileChosen As Integer
Dim file As Object
MyPath = ThisWorkbook.Path & "\Avtaler\" & LeggTil.tbAvtalenummer.Value & ".pdf"
'FileChosen = FileDialog.Show
dialogTitle = "VELG AVTALEFIL"
Set FileDialog = Application.FileDialog(msoFileDialogFilePicker)
Set FileDialog1 = Application.FileDialog(msoFileDialogFilePicker)
With FileDialog
.InitialFileName = tbAvtalenummer.Value
.AllowMultiSelect = False
'.Filters.Clear
.Title = dialogTitle
.Show
End With
If FileDialog.Show <> -1 Then
MsgBox "test"
Else: Application.FileDialog1 (msoFileDialogSaveAs)
End If
End Sub
Any tips on how to accomplish this?
Thanks in advance
Bookmarks