Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

calling the "browse" dialog from with Word Macro

1 view
Skip to first unread message

BRC

unread,
Oct 31, 2003, 8:21:01 PM10/31/03
to
I have a word dialog that I wrote in Vb that displays a dialog box where
user can set the path(s) to different form letters they use. Currently the
dialog box has 5 textboxes that user can type paths into. What i would like
to do is call the "browse" dialog and return the selected path to the
textbox. Can anyone steer me to something that might help. Thanks in
advance for any ideas. BRC


Jay Freedman

unread,
Oct 31, 2003, 9:26:10 PM10/31/03
to
Have a look at http://www.mvps.org/ccrp/controls/ccrpcontrols.htm and see if
the Browse Server is what you want.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://www.mvps.org/word

Lars-Eric Gisslén

unread,
Nov 1, 2003, 6:09:56 AM11/1/03
to
You can use the following code to display the BrowseForFolder dialog:
(Include a reference to 'Microsoft Shell Controls and Automation' in your
VBA project)

Dim oShell As Shell32.Shell
Dim oFolder As Shell32.Folder

Set oShell = New Shell32.Shell
Set oFolder = oShell.BrowseForFolder(0, "Select a folder for your
files", 0)

MsgBox oFolder.Self.Path

Set oFolder = Nothing
Set oShell = Nothing

Regards,
Lars-Eric


"BRC" <bur...@yahoo.com> skrev i meddelandet
news:uSQxqZB...@tk2msftngp13.phx.gbl...

BRC

unread,
Nov 1, 2003, 11:39:19 AM11/1/03
to
This seems to be a pretty easy way to do this but i am getting an error it
the message box line
"Run-time error 438 object doesn't support this property or method" The
browse function seems to work fine but i can't return a reference to the
folder i select. thanks again for your help
BRC

"Lars-Eric Gisslén" <lars.gisslen@_DelUnderscoreAndBetween_chello.se> wrote
in message news:JtMob.344$%W3.46@amstwist00...

Lars-Eric Gisslén

unread,
Nov 1, 2003, 1:30:22 PM11/1/03
to
Ok,

That is the AxtiveX interfaces to the underlying Win API functions in a
nutshell. Not 100% reliable! Ok, no reason to give up. Next step would be to
call Win API directly, but, try this code first:
'-------------------------------------
Sub Test()
MsgBox GetFolderName("Choose a folder")
End Sub

Function GetFolderName(sCaption As String) As String


Dim oShell As Shell32.Shell
Dim oFolder As Shell32.Folder

Dim oItems As Shell32.FolderItems
Dim Item As Shell32.FolderItem

On Error GoTo CleanUp

Set oShell = New Shell ' ActiveX interface to shell32.dll
Set oFolder = oShell.BrowseForFolder(0, sCaption, 0)
Set oItems = oFolder.Items
Set Item = oItems.Item

GetFolderName = Item.Path

CleanUp:
Set oShell = Nothing
Set oFolder = Nothing
Set oItems = Nothing
Set Item = Nothing

End Function
'-------------------------------------

Regards,
Lars-Eric

"BRC" <bur...@yahoo.com> skrev i meddelandet

news:%230rk1aJ...@TK2MSFTNGP12.phx.gbl...

BRC

unread,
Nov 6, 2003, 9:33:01 PM11/6/03
to
I havn't tried your 2nd suggestion but I did find that by simply removing
the ".Self.Path" from the "oFolder.Self.Path" in the first example you gave
me, I was able to return the path in a msgbox. so i am sure i can make that
work once i have time to play with it a little. Thanks for the great input.

"Lars-Eric Gisslén" <lars.gisslen@_DelUnderscoreAndBetween_chello.se> wrote
in message news:DWSob.406$%W3.425@amstwist00...

Lars-Eric Gisslén

unread,
Nov 7, 2003, 5:20:44 PM11/7/03
to
BRC,

Are you on Windows 98?

Self is only supported in shell32.dll version 5.0 or later - Win 2000/ME and
later.
My second example should work with no problems.

Regards,
Lars-Eric


"BRC" <bur...@yahoo.com> skrev i meddelandet

news:%230rk1aJ...@TK2MSFTNGP12.phx.gbl...

0 new messages