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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Common Dialog needs to be manually coded

Status
Not open for further replies.

hendrixharrison

Technical User
Mar 15, 2005
16
CA
My microsoft access doesnt have license to use the microsoft common dialog control and hence I am forced to code it manually.

Using the code down below, I somehow forgot how and where should I declare these objects.


this code line needs to be declared

Dim cmdlgOpenFile As New clsCommonDialog

dim clsCommonDialog as ?

I just couldnt remember this at the moment and need help.

So does anyone know how to fix this?
 
If you pasted the class module code in a class module and named it "clsCommonDialog" then you're ready to use it from a form. Put a button on the form and set it's OnClick property to [Event Procedure], then in the code window:
Code:
Private Sub cmdGetFile_Click()
  Dim cmdlgOpenFile As New clsCommonDialog
  Dim FileName As String    'full file name
  Const clngFilterIndexAll = 5

  cmdlgOpenFile.Filter = "Text Files (*.txt)|*.txt|DBF Files (DBF)|*.dbf|All Files (*.*)|*.*"
  cmdlgOpenFile.FilterIndex = clngFilterIndexAll
  'this is where the dialog opens
  [blue]cmdlgOpenFile.ShowOpen[/blue]

  'returns your full file name.
  FileName = cmdlgOpenFile.FileName

  'hence no len, no name...
  If Len(FileName) = 0 Then Exit Sub

  'do stuff with the filename here....
End Sub
The blue line opens the dialog. When you're coding, as soon as you type [tt]cmdlgOpenFile.[/tt] the methods and properties of the class will appear on the intellisense help.

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top