Results 1 to 9 of 9
  1. #1
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    object not found (Excel 2003)

    Hi all,
    I keep getting this error when I try and use a commondialog box with an image control.

    Does anyone see a porblem with the code?

    Thanks Darryl.

    my error starts at .InitDir = "P:PlatemakingMiscINVENTORY_GRAPHICSMASS_IMPACT_GR APHICSTEST PDF DESTINATIONthumbnails"


    Public sub GO_Click()
    Dim strfile As String
    With CommonDialog1
    .InitDir = "P:PlatemakingMiscINVENTORY_GRAPHICSMASS_IMPACT_GR APHICSTEST PDF DESTINATIONthumbnails"
    .DialogTitle = "Select image file to diplay"
    .ShowOpen
    If .Filename = "" Then
    MsgBox "Please enter a file name"
    Else
    strfile = .Filename
    Debug.Print strfile
    Image1.Picture = LoadPicture(.Filename)
    End If
    End With
    frmImage.Repaint
    ActiveSheet.Range("A57").Value = strfile
    Me.Label1.Caption = Mid(strfile, 108, 3)
    frmImage.Caption = ActiveSheet.Name
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: object not found (Excel 2003)

    Where is the GO_Click procedure? In the module belonging to the userform that contains CommonDialog1?

  3. #3
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: object not found (Excel 2003)

    Hi Hans,

    Yes it is, I think I might have figured out the problem, the problem could the path name.

    Thanks,
    Darryl.

  4. #4
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: object not found (Excel 2003)

    Hans,

    Could the problem stem from an XP issue Platform?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: object not found (Excel 2003)

    Not as far as I know - why do you think so?

  6. #6
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: object not found (Excel 2003)

    Hi Hans,

    Commondialog, I had them loaded on a form, then on another machine they were wiped off when the file was loaded, do I need to have a commondialog box when opening the file that way in which I do, I woudl like to open a specific folder on a server to save time by not having to travel our network, on my machine the commondialog box remains, no problem, but there is a could not load, not available on this machine statement, I'm figuring this is the cause of my Error Object required.

    Thanks
    D

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: object not found (Excel 2003)

    If all your users have Excel 2002 or higher, you can use the Application.FileDialog object. This is not available in Excel 2000 or earlier, however, so if some of your users have that, you can't use FileDialog.

    The FileDialog object has a property InitialFilename that lets you specify where to start looking. Look up FileDialog in the Excel VBA help, and do a search in this forum for examples.

  8. #8
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: object not found (Excel 2003)

    Hi Hans,

    I wanted to say thanks for your help on this, I have been away for a couple of weeks,
    I checked out the help on this topic and found my solution, I do have a minor problem when the user selects nothing, and cancels out of the filepicker. I have been trying to set the object but can not get it to work in case the user cancels. The initalfilename? is this considered a property of the filediaolg? AND if so, is this a case where I might use a property let and get statement?

    Thanks,
    Darryl.

    Private Sub Image1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Dim fd As FileDialog
    Dim strFilename As String
    Dim i As String
    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    With fd
    .AllowMultiSelect = True
    .InitialFileName = "P:PlatemakingMiscINVENTORY_GRAPHICSMASS_IMPACT_GR APHICSTEST PDF DESTINATIONimages"
    .Show
    .Filters.Clear
    .Filters.Add "MASS IMPACT PICTURES", "*.JPG"
    i = fd.SelectedItems(1)
    End With
    Debug.Print i
    With Image1
    .Picture = LoadPicture(i)
    End With
    frmImage.Repaint
    ActiveSheet.Range("A57").Value = i
    Me.Label1.Caption = Mid(i, 108, 3)
    frmImage.Caption = ActiveSheet.Name
    Set fd = Nothing
    End Sub

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: object not found (Excel 2003)

    There's no point in setting MultiSelect to True if the user is selecting a single picture for an image control.
    There's no point in setting the filter after showing the dialog. You should set it before doing so.
    Assuming that images is a folder, there should be a backslash after it, otherwise VBA will assume that images is a file name.
    Using i as variable name for a string is technically correct, but unusual and confusing, since i is traditionally used to indicate an integer.
    The Show method returns True if the user clicked OK, False if the user clicked Cancel, so you can test for that:

    Private Sub Image1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Dim fd As FileDialog
    Dim strFilename As String
    Dim i As String
    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    With fd
    .AllowMultiSelect = False
    .InitialFileName = "P:PlatemakingMiscINVENTORY_GRAPHICSMASS_IMPACT_GR APHICSTEST PDF DESTINATIONimages"
    .Filters.Clear
    .Filters.Add "MASS IMPACT PICTURES", "*.JPG"
    If .Show Then
    i = fd.SelectedItems(1)
    Debug.Print i
    Image1.Picture = LoadPicture(i)
    frmImage.Repaint
    ActiveSheet.Range("A57").Value = i
    Me.Label1.Caption = Mid(i, 108, 3)
    frmImage.Caption = ActiveSheet.Name
    End If
    End With
    Set fd = Nothing
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •