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

Re: Ask the working path to the user by macropod

macropod
Fri Oct 12 14:47:22 PDT 2007

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" <stephanevial@gmail.com> wrote in message news: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
>


Re: Ask the working path to the user by Steff

Steff
Mon Oct 15 11:48:30 PDT 2007

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:=3D"Find a Folder", RootFolder:=3D&H11)
> End Sub
>
> Function GetFolder(Optional Title As String, Optional RootFolder As Varia=
nt) As String
> On Error Resume Next
> GetFolder =3D 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'. F=
or 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 act=
ually been selected.
>
> Cheers
> --
> macropod
> [MVP - Microsoft Word]
> -------------------------
>
>
>
> "Steff" <stephanev...@gmail.com> wrote in messagenews:1192222172.638899.4=
5680@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=E9c=E9dents -
>
> - Afficher le texte des messages pr=E9c=E9dents -

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


Re: Ask the working path to the user by macropod

macropod
Mon Oct 15 14:11:17 PDT 2007

">
> > 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

Hi Stephane,

They should both go in the same standard module.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------


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


Re: Ask the working path to the user by Steff

Steff
Mon Oct 22 09:46:03 PDT 2007

On 20 oct, 01:25, Russ <drsN0SPAMmi...@hotmailD0Tcom.INVALID> wrote:
> 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 =3D GetFolder(Title:=3D"Find a Folder", RootFolder:=3D&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:=3D"Find a Folder", RootFolder:=3D&H11)
> >> End Sub
>
> >> Function GetFolder(Optional Title As String, Optional RootFolder As Va=
riant)
> >> As String
> >> On Error Resume Next
> >> GetFolder =3D CreateObject("Shell.Application").BrowseForFolder(0, Tit=
le, 0,
> >> RootFolder).Items.Item.Path
> >> End Function
>
> >> The selected folder name is stored in the variable 'MyFolder'.
>
> >> To have the sub run au