Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding VB6 code to access 97/2k

Status
Not open for further replies.

Taha60

Technical User
Jun 21, 2002
54
CA
Hello everyone... :)

I found very good code that would I would like to include into my access app. at
Can anyone sugggest as to how I can encorporate that code into my access appilcation.

I was thinking of making it an ACTIVEX then inserting the activeX into my access 2k/97 since I dont know if that raw code (i think it was made for vb6) will work in access 97/2k...

I am open to lots of suggestions...

Thanks
Taha
thamiral@uwo.ca
Taha
thamiral@uwo.ca
 
Should work in 97

Just give it a quick Test by:

1) creating a new form
2) Add a button to the form
3) Right click on the button and select Properties
4) Select the ALL tab
5) Select the Name Property
6) Rename the button as TestAPI
7) Select the Events Tab
8) Select the OnClick event and press the ... button
9) Paste the following code into the module
10) Test it


Private Const BIF_RETURNONLYFSDIRS = 1
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const MAX_PATH = 260

Private Declare Function SHBrowseForFolder Lib _
"shell32" (lpbi As BrowseInfo) As Long

Private Declare Function SHGetPathFromIDList Lib _
"shell32" (ByVal pidList As Long, ByVal lpBuffer _
As String) As Long

Private Declare Function lstrcat Lib "kernel32" _
Alias "lstrcatA" (ByVal lpString1 As String, ByVal _
lpString2 As String) As Long

Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type


Private Sub TestAPI_Click()

'Opens a Browse Folders Dialog Box that displays the
'directories in your computer
Dim lpIDList As Long 'Declare Varibles
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo

szTitle = "Hello World. Click on a directory and " & _
"it's path will be displayed in a message box"
'Text to appear in the the gray area under the title bar
'telling you what to do

With tBrowseInfo
.hWndOwner = Me.Hwnd 'Owner Form
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
End With

lpIDList = SHBrowseForFolder(tBrowseInfo)

If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
MsgBox sBuffer
End If

End Sub

 
Hello ..

I would really like to apologize for the multi post ...

I am new to this area and double clicked once too many times on the submit post button in order to avoid the "preview postpage from loading ... ( I am used to clicking preview post )

Thanks Taha
thamiral@uwo.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top