AspiredWrite
09-12-2016, 01:05 AM
I've scoured the internet and can't find a solution that works despite this being an elemental thing to do.
when I create a SaveAs dialog in Word VBA it doesn't save the file, that needs to be done seperately. But to where? All I've managed is to get the file name to save but not the path and if the user decides to change the location inside the Save As dialog, how do I get the path to save to?
I've tried
dim adress as string
adress = Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1)
as suggested here and there but I get a runtime error (5): "Invalid procedure call or argument"
this is my code:
Sub ShowSaveAsDialog()
Dim a As String
a = "cancelled"
With Dialogs(wdDialogFileSaveAs)
If .Display <> 0 Then
a = Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1) 'this throws the above error
' a = .name 'alternate. this gives just the filename without the full path
End If
End With
msgbox a
End Sub
This must be simple right? Help please!
when I create a SaveAs dialog in Word VBA it doesn't save the file, that needs to be done seperately. But to where? All I've managed is to get the file name to save but not the path and if the user decides to change the location inside the Save As dialog, how do I get the path to save to?
I've tried
dim adress as string
adress = Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1)
as suggested here and there but I get a runtime error (5): "Invalid procedure call or argument"
this is my code:
Sub ShowSaveAsDialog()
Dim a As String
a = "cancelled"
With Dialogs(wdDialogFileSaveAs)
If .Display <> 0 Then
a = Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1) 'this throws the above error
' a = .name 'alternate. this gives just the filename without the full path
End If
End With
msgbox a
End Sub
This must be simple right? Help please!