Re: Ask the working path to the user by Russ
Russ
Fri Oct 19 22:25:09 PDT 2007
Steff,
In case you didn't notice it subroutine Browse() was missing a couple of
things, a declaration and an equal character for an assignment for the
MyFolder variable. When added, everything works great for me. :
Sub Browse()
Dim MyFolder As String
MyFolder = GetFolder(Title:="Find a Folder", RootFolder:=&H11)
End Sub
> On 12 oct, 17:47, "macropod" <inva...@invalid.invalid> wrote:
>> Hi Steff,
>>
>> The following sub & function shows how you can browse for a folder:
>>
>> Sub Browse()
>> MyFolder GetFolder(Title:="Find a Folder", RootFolder:=&H11)
>> End Sub
>>
>> Function GetFolder(Optional Title As String, Optional RootFolder As Variant)
>> As String
>> On Error Resume Next
>> GetFolder = CreateObject("Shell.Application").BrowseForFolder(0, Title, 0,
>> RootFolder).Items.Item.Path
>> End Function
>>
>> The selected folder name is stored in the variable 'MyFolder'.
>>
>> To have the sub run automatically, you could rename it 'Document_Open'. For
>> other options, look under 'Auto Macros' in Word's help
>> file. You might also want to add some code to check that a folder has
>> actually been selected.
>>
>> Cheers
>> --
>> macropod
>> [MVP - Microsoft Word]
>> -------------------------
>>
>>
>>
>> "Steff" <stephanev...@gmail.com> wrote in
>> messagenews:1192222172.638899.45680@i38g2000prf.googlegroups.com...
>>> Hi,
>>
>>> I would like to pop up a form when the document open and asking user
>>> the working folder by browsing until the folder. Store the folder path
>>> into a public variable.
>>
>>> Thanks
>>
>>> Stephane Vial- Masquer le texte des messages précédents -
>>
>> - Afficher le texte des messages précédents -
>
> Hello,
>
> When a tried to execute the code, a have the following error message
>
> Compile error : Sub or Function Not Define
>
> I put the sub in a modules and the function in a class modules !!
>
> Thanks for your help
>
> Stephane
>
--
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID