That code is verbatim from my web site
(www.cpearson.com/Excel/BrowseFolder.htm), and it works for me. I just tried
it in both Excel 2003 and Excel 2007 on both Windows XP Pro SP2 and Windows
Vista Ultimate. It works fine. Put your cursor inside the OpenMyBrowser sub
and then press the F8 key to step through the code line by line. Does the
browse folder dialog display? Do you get an error?
Just for diagnostics, change
ID = SHBrowseForFolderA(BrowseInfo)
to
ID = SHBrowseForFolderA(BrowseInfo)
MsgBox "Last DLL Error: " & CStr(Err.LastDLLError)
If the MsgBox displays anything but 0, then the call to SHBrowseForFolderA
failed and you can decode the Err.LastDLLError using other code on my web
site (http://www.cpearson.com/Excel/FormatMessage.aspx).
By the way, the line of code
Dim FName, SUBDIR, ROOTDIR As String
probably isn't doing what you think it is. It does NOT declare all these
variables as Strings. It declares FName and SUBDIR as Variants and only
ROOTDIR as a String. It is the same as
Dim FName As Variant, SUBDIR As Variant, ROOTDIR As String
However, this should not cause any problems.
Also, you should almost NEVER use the "End" statement. It is a poor
programming practice that can cause unexpected problems.
And on a final note, your computer's clock is wrong. Please fix it.

Signature
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
> Hi again,
> My appologize. Sorry I forget to mentions that I'm using 2 types of code
[quoted text clipped - 82 lines]
> Thanks in advance.
> Jaemun.
Jaemun - 25 Sep 2007 21:36 GMT
Hello Chip Pearson,
Thanks for the advice. I totally agree with you. Because I did tested your
code using Office 97 - 2007 on Windows 98 - Vista Ultimate. And they works
great!
I don't know what cause the system on my computer cannot run the code. Even
after I reformat my computer I still can't run the code.
Ok, now I've already diagnost the codes as you have advised me to do. Please
examine the result below:-
If ID Then '<--------the "step into" cursor stop at this line.
Res = SHGetPathFromIDListA(ID, FolderName)
If Res Then
BrowseFolder = Left$(FolderName, InStr(FolderName, _
vbNullChar) - 1)
End If
End If '<---------then continue at this line
In addition, the message box displayed error as "0".
Thanks in advance,
Jaemun.
Chip Pearson - 25 Sep 2007 22:23 GMT
If code execution resumes at the second "End If" following the "If ID Then"
line, that means that the ID variable has a value of 0. According to MSDN,
this will occur only if the user click's Cancel on the dialog. Beyond that,
I have no idea why the function would fail. The Knowledge Base has nothing
relevant on the topic.

Signature
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
> Hello Chip Pearson,
>
[quoted text clipped - 23 lines]
> Thanks in advance,
> Jaemun.
Jaemun - 25 Sep 2007 23:55 GMT
Dear Chip Pearson,
I never thought "Kaspersky Anti-Virus Personal Pro" has blocked the macros.
It probably change the setting after an automatic update.
Since the code execute an API Function "SHBrowseForFolderA" and
"SHGetPathFromIDListA" from shell32.dll, therefore I have make a minor
changes to Kaspersky AVPP setting:-
- Realtime protection settings
- Macros
- Calling to API Function (I set to "Allow execution")
Now the code works great!
Anyway, many thanks and appreciations for your help. Your advices / briefs
really help me to understand the code better.
Kind Regard,
Jaemun,