|
-
Oct 6th, 2000, 10:11 AM
#1
Thread Starter
Member
Hello all,
can someone tell me what I'm doing wrong? I'm trying to display a CommonDialog1 for the user to select a file and the code that I'm using works because I tested it however, when I place it in my program it doesn't work and gives me the following error: "Object Required"
======================
Here's my code
--------------
Private Sub cmdBrowsePDFFile_Click()
On Error Resume Next
With CommonDialog1
.CancelError = True
.DialogTitle = "Testing Browse"
.Filter = "*.pdf"
.flags = cdlOFNHideReadOnly + cdlOFNFileMustExist
.ShowOpen
If Err = cdlCancel Then
Exit Sub
End If
txtPDFFile.Text = .FileName
End With
ErrHandler:
' User pressed the Cancel button
End Sub
============================
My modules:
-----------
Option Explicit
Public 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
Public Const BIF_RETURNONLYFSDIRS = 1
Public Const MAX_PATH = 260
Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
-
Oct 6th, 2000, 10:15 AM
#2
transcendental analytic
Where does the error occur?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 6th, 2000, 10:20 AM
#3
Thread Starter
Member
as soon as it goes into the function -- if I REM out the first line: "On Error Resume Next"
then it stops at "With CommonDialog1"
Thanks!
-
Oct 6th, 2000, 10:32 AM
#4
_______
<?>
Works fine for me.
Do you have the dialog control on your form?
Also, your filter is wrong:
should be like this:
.Filter = "PDF Files(*.pdf)|*.pdf*"
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 6th, 2000, 10:33 AM
#5
transcendental analytic
Is the commondialog control in another form? Is the code in a module?
Then you'd have to refer to the control as an item of the form
Code:
with form1.Commondialog1
BTW, is the commondialog named Commondialog1?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 6th, 2000, 10:50 AM
#6
Thread Starter
Member
Hello all,
I don't know how this happened but I think I acidently deleted the CommonDialog control -- I added it back in and now it works! Just one more question, does anyone know how to set the default path when the CommonDialog appears. For, example, I want it to display c:\test
Thanks!
Marci
-
Oct 6th, 2000, 11:02 AM
#7
_______
<?>
CommonDialog1.InitDir = "C:\Test"
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|