Results 1 to 7 of 7

Thread: [RESOLVED] CommonDialog1 "object not found"

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    6

    Resolved [RESOLVED] CommonDialog1 "object not found"

    I'm currently editing someone else's code, paring a large program down to some small features that I want to be more portable.

    In the process, a fairly mundane reference to CommonDialog (the "preferred" Open-File dialog reference) stopped working. It now produces an "object not found" error on the first reference it encounters. The code looks like:

    Code:
    'open dialog box to ask for control line report filename (text file)
    CommonDialog1.DialogTitle = "Control Line Report Filename"    'dialog box title
    CommonDialog1.Filter = "All Files (*.*)|*.*|CommandFile (*.txt) |*.txt|"    'filename extensions
    CommonDialog1.FilterIndex = 2           'filename filter to txt (default filename)
    CommonDialog1.filename = ""             'clear dialog textbox
    CommonDialog1.CancelError = True        'allow cancel button function
    CommonDialog1.ShowOpen                  'show the dialog box
    filename = CommonDialog1.filename       'textbox filname for output
    I've searched the web. It looks like comdlg32.ocx must be present... it (still) is. The previous code runs fine on my system, and has no explicit references to comdlg32.ocx, nor to CommonDialog1, except as noted in the code above.

    I've basically given up and started all over from scratch with the working legacy code, but at any moment whatever I broke before might break again...

    Any clues?

  2. #2
    Junior Member Pascal.Scholtes's Avatar
    Join Date
    Jun 2005
    Location
    Saarbrücken / Germany
    Posts
    26

    Re: CommonDialog1 "object not found"

    I can't help with the problem itself, but you can free your programs from runtimes using the API. In this case I'd recommend "GetOpenFileName".
    Last edited by Pascal.Scholtes; Oct 13th, 2011 at 05:57 PM. Reason: Link added
    Look busy. Jesus is coming.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    6

    Re: CommonDialog1 "object not found"

    Thanks. So noted. But it does entail changing even more legacy code... So I'll do it if the problem recurs, I suppose.

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: CommonDialog1 "object not found"

    To begin with, you can't use an object unless it exists. So you need to have a CommonDialog control with that name someplace, such as on the Form you are working with there.

    "Object not found" sounds like a compile-time error (which can appear when trying to run within the IDE of course). The project should fail to compile when you do a Make on it.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    6

    Re: CommonDialog1 "object not found"

    Ah! One of those hidden controls, that's really just a placeholder for the code it carries! Gotcha!!!

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    6

    Re: CommonDialog1 "object not found"

    dilettante, a winner is you. That worked. And it explains why the code broke at some random point in my cleanup process - I caught the control in a selection sweep of other controls I was deleting.

  7. #7
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: CommonDialog1 "object not found"

    Glad to hear it. You can mark this resolved by using Thread Tools just above your first post here.

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