"VBA GetFile in MS Word" Tue Oct-25-05 02:06 AM by _Chewy_
Steve,
Back to my RFI project again using the form letter that I mentioned in my previous thread. What I want is VBA to look at a series of words contained within a Bookmark range called "Transplant Types" (located at very end of paragraph 1). So if ABC Hospital specializes in Adult Heart and Adult Liver, I want VBA to go to a specific folder, retrive word files named "Section 1 Heart.doc" and "Section 4 Liver.doc". Of course depending the hospital's specialty, I want it to retrieve the correct word documents. There are about 10 different types in all.
Tonight I fooled around with the VBE help file menu but I'm gettin nowhere. I took bits and pieces of code I found on the internet in a vain attempt to try to do this w/out any expert help. I think it's getting caught up on the GetFile command. I keep getting an error message "Requested member of the class or object cannot be found" or something like that.
I'm lost - can you point me in the right direction?
#1. "RE: VBA GetFile in MS Word" In response to _Chewy_ (Reply # 0) Tue Oct-25-05 01:25 PM by SteveYandl
For what I think you want to do, it might be simpler to use the 'Documents.Open' rather than GetFile.
GetFile is a member of the FileSystemObject which is part of the scripting runtime. In short, it isn't part of VBA. If you want to use it in a VBA project, open the VBE, click 'Tools > References' and put a check mark next to the listing "Microsoft Scripting Runtime". You also need to create an instance of the object, "Scripting.FileSystemObject" before you can utilize GetFile.