Please help!
Microsoft's online help and Google searches seem to go in circles here, and I keep coming back to the same set of contradictions.
I'm writing a Macro in Microsoft Word 2010. This macro must save a datafile that contains some comma delimited data, and prompt the user for the path and file name.
The following code:
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogSaveAs)
Works, but it forces the extension to be ".docx". I want it to be my own extension, say ".foobar" or something. Ideally, I want the user to be able to type the file name and have it automatically add ".foobar" to the file name.
So, when I try to do this:
fd.Filters.Add "Foobar files", "*.foobar", 1
... VBA gives me an error that msoFileDialogSaveAs doesn't support filters.
Okay, fine, all the stuff on the web says that when I hit this problem, change it to a file picker dialog:
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
That's fine and the filters work at that point, but NOW THE USER CAN'T SAVE THE FILE!. The dialog picker only works if you PICK AN EXISTING FILE, and if the user types in their own file name, then there's a "sorry file does not exist error" and the user can't save the file.
When I try searching to find out how to "Save as" with msoFileDialogFilePicker, they all say either "it should work" (it doesn't) or they say to use msoFileDialogSaveAs instead, wash rinse repeat.
Someone please help me out of this vicious circle?
NOTE: suggestions to use something other than Word or VBA will not be helpful. This has to be coded in the Word for Windows Version 10 macro language in order for it to be useful.
How do I SAVE AS WITH FILTERS in the Word VBA macro language? Anyone know?