Results 1 to 7 of 7

Thread: simple question?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Posts
    52

    Unhappy

    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

    Marci Sarwan

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Posts
    52
    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!
    Marci Sarwan

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    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

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Posts
    52
    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
    Marci Sarwan

  7. #7
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    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
  •  



Click Here to Expand Forum to Full Width