office 2000 premium compatibliy issue???

J

Jacob Patzer

ok here's a question for all of you VBA Gurus out there. Havent found
anyone to be able to tell me if this is a problem. Am running XPhome
completely upgraded with office 2000 premium.....and have written a
short routine in VBA WHICH runs on 98 machines. AM getting a run time
error 453 that something is wrong with the shell32.dll on the xp
machine. Have looked and the dll is there 7.80 mb...... following the
code:
-----------------------------------------------------------------------------
Option Explicit

Public Type BROWSEINFO
h0wner As Long
pidlroot As Long
pszDisplayName As String
lpszTitle As String
ulflags As Long
lpfn As Long
lparam As Long
iimage As Long
End Type

Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long
Declare Function SHBrowserForFolder Lib "shell32.dll" _
Alias "SHBrowserForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
---------------------------------------------------------------------

Function dirauswahl()
Dim msg As String
msg = "choose a folder"
dirauswahl = getdirectory(msg)
End Function
---------------------------------------------------------------------
Function getdirectory(Optional msg) As String
Dim BINFO As BROWSEINFO
Dim path As String
Dim r As Long, x As Long, pos As Integer
BINFO.pidlroot = 0&
If IsMissing(msg) Then
BINFO.lpszTitle = "choose a folder"
Else
BINFO.lpszTitle = msg
End If

BINFO.ulflags = &H1
----> x = SHBrowserForFolder(BINFO)
path = Space$(512)
r = SHGetPathFromIDList(ByVal x, ByVal path)
If r Then
pos = InStr(path, Chr$(0))
getdirectory = Left(path, pos - 1)
Else
getdirectory = ""
End If

End Function
 
P

Peter Hewett

Hi Jacob

I'm no guru, so you're plumb out of luck but, I'm wondering whether it's
the way you're using your UDT - BROWSEINFO.

VBA internally uses Unicode strings. So if you're call a procedure that
expects ANSI strings (the A suffix on the API function names) you need to
convert the Unicode strings to ANSI strings.

So where your UDT declares an element "As String" try changing your code
from:
BINFO.lpszTitle = msg
to:
BINFO.lpszTitle = StrConv(msg, vbFromUnicode)

Do this in all cases.

Let me know how you get on.

HTH + Cheers - Peter


(e-mail address removed) (Jacob Patzer) wrote in
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top