Link to home
Start Free TrialLog in
Avatar of WestBillWest
WestBillWest

asked on

User Type not defined

When compiling - Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long  I get an error User Type not defined.  I've gone to references, and tried to open "c:\windows\system32\comdlg32.dll".  I get a message "Can't add a reference to the specified file".   I am using MS Access 2007.  I need the Directory and Folder control.
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

I use the API at:  http://access.mvps.org/access/api/api0001.htm

In this API, there is a Type statement at the beginning tagOPENFILENAME which defines the type.  Your application should have a similar Type statement.
Hi,

I not sure of this, but have you check for Filesystemobject, FSO for the function you like to use. FSO is mostly use in VB environment to deal with files and folder.

For your problem, you need to define the type by yourself. No all .dll can be set as reference. Add this to your code and try compile your application once more.

Type OPENFILENAME
	lStructSize As Long
	hwndOwner As Long
	hInstance As Long
	lpstrFilter As String
	lpstrCustomFilter As String
	nMaxCustomFilter As Long
	nFilterIndex As Long
	lpstrFile As String
	nMaxFile As String
	lpstrFileTitle As String
	nMaxFileTitle As String
	lpstrInitialDir As String
	lpstrTitle As String
	flags As Long
	nFileOffset As Integer
	nFileExtension As Integer
	lpstrDefExt As String
	lCustData As Long
	lpfnHook As Long
	lpTemplateName As String
End Type

Open in new window

Avatar of WestBillWest
WestBillWest

ASKER

I can not use anything that has to do with the comdlg32.dll.  I see it but I can not register it.   I am not an expert and I am having trouble following your solutions.  I need a way for the user to select directories, folders, and files from a control.  Using list boxes is a real pain because of subdirectories/folders.  Could be as simple as I may not know how to view all of the available controls from the menu bar.  I have selected Microsoft Common dialog Control 6.0 (C:\Windows\System32\mscomct2.ocx) in references.  Help...
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great, worth every dime.  Hopefully someday I can help somebody..