ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   namespace.pickfolder (https://www.excelbanter.com/excel-programming/338905-namespace-pickfolder.html)

Steve[_63_]

namespace.pickfolder
 
hi all

if i get a user to pick an outlook folder with the
namespace.pickfolder method, how can I make that folder object
available across all my macros - i need to refer to it again in some
userform.dblclick events

i don't want the make the user select a folder each time I want to
refer to it

any help appreciated, new to vba
tia
steve

Robin Hammond[_2_]

namespace.pickfolder
 
Steve,

You could save it in the registry. In subsequent routines, if there is a
registry entry, then use it, otherwise prompt for the folder.

Have a look at savesetting and getsetting in the help files.

Robin Hammond
www.enhanceddatasystems.com

"Steve" wrote in message
...
hi all

if i get a user to pick an outlook folder with the
namespace.pickfolder method, how can I make that folder object
available across all my macros - i need to refer to it again in some
userform.dblclick events

i don't want the make the user select a folder each time I want to
refer to it

any help appreciated, new to vba
tia
steve




K Dales[_2_]

namespace.pickfolder
 
No need to monkey with the registry unless you want the selection to be saved
as a user setting (e.g. will be saved even if Excel closed or computer is
shut down).

Simpler: make the folder into a Public (global) variable; then you can
access it from other routines (even in other modules); e.g:

Public SelectedFolder as MAPIFolder

Sub FolderPick()
' This would be the routine where the user picks the folder
Set SelectedFolder = ...
End Sub

Sub UserForm_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
' This sub can use SelectedFolder as an object variable; if called after the
FolderPick sub, SelectedFolder will contain the folder chosen in FolderPick
End Sub

--
- K Dales


"Steve" wrote:

hi all

if i get a user to pick an outlook folder with the
namespace.pickfolder method, how can I make that folder object
available across all my macros - i need to refer to it again in some
userform.dblclick events

i don't want the make the user select a folder each time I want to
refer to it

any help appreciated, new to vba
tia
steve



All times are GMT +1. The time now is 10:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com