I need help with VB in a MS Word 2000 macro/form, hope I’m in the right place.

We have created templates (with help from a VB 6 programmer) that have a form to fill in information on the word doc. I need to make a major upgrade (the original programmer is not available).

I need to be able to fill a variable with a chosen file (or files) path. I created a txtBox on the form (for the template), and after some searching on the Internet, found some code to make a button launch a windows explorer window to a specific directory.

What I would like to do now is be able to highlight one or more files in windows explorer and somehow have their paths fill a variable. I found some code that will fill a listbox with a file path if you drag it and drop it. The instructions said to “Set the Form OLEDropMode Property to 1 - manual”. I can’t find such a creature on this template’s VB form. So for now, I’m still looking around.

Any ideas on creating a variable from the path of a highlighted file in Windows Explorer on my VB form built into my word 2000 template??

Thanks…

Mike

Recommended Answers

All 3 Replies

The code you found is for VB6, not VBA. The VB Editor INSIDE of office (excel, word, etc) is VBA (Visual Basic For Applications) which is a stripped down version of actual visual basic. It lacks some major functionality required to be a full-fledged programming language. As far as I can tell, the user forms in VBA don't offer the kind of control for dragging and dropping files from explorer. Visual Basic 6 DOES offer this, but that doesn't help you at all with your problem in VBA. It doesn't even seem like it will allow us to create a drivelist or filelist box control with early or late binding in VBA..... The only way I would imagine doing it, would be with a full-fledged VB app, and having that App use the word document as a backend...

Okay…that’s not what I had hoped for, but…

Is there another way to get VBA to load a variable that is the path of a selected file? I have these templates already constructed and being used, if there is a way to not start over, that would be preferred.

Thanks

Mike

If all the templates are (or, if you can make them) stored in the same directory (in the same folder), then you could make VBA gather a list of all the template files in the folder, and display that in a listbox (this would require some redesign, so that you would no longer need/use the explorer in a specific folder). Then, allow the user to select an item in the listbox (a filename) and do whatever you'd like with it....... that's about the closest you can get to it....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.