I love learning VBA and would gladly spend hours trying to figure this out, but don't have that much time. Keep in mind this is Word VBA not excel but it should be similar enough I ***
The following code works perfectly at extracting a page in word and saving it into a static directory. The problem is I want the user to be able to dynamically choose the directory with a FileDialogue object. I keep running into issues/errors.
This code works but is static.
I can't remember whom to credit for that code but I didn't write it.
Now I try to use FileDialogue.show() method to pick a directory and in some of the attempts below I did get that box to appear.
I first tried changing
and nothing else, but that gave a runtime error 5152 This is not a valid filename. I assume because it's not returning a string. In fact I had it printed to a messagebox and it returns a -1. (Huh? Why would it return a mere code and not something more substantive?)
and I tried adding
I tried different values as argument including -1)
That gave a runtime error 424 Object required. I read the docs on that so I tried using dim fldr as FileDialogue and then
set fldr = Application.FileDialog(msoFileDialogFolderPicker).Show
but that got a compile error object required.
what does Application.FileDialogue.show() actually return? One might assume it returns a string, or a FileDialogue object that can be converted to a string.
I read the docs and I searched google and S/O. It seems people had similar questions and got answers but they weren't clear enough for me and I'm not sure they addressed the issue. If I could spend a day at this I'm sure I could get it and learn a lot in the process. The lightbulb is getting brighter inside of me every day but it's a slow process. Thanks. I just wanted to put this out there before I shut down for the day so I don't forget what I did.
Bookmarks