Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. VB Shell Folder error handler

VB Shell Folder error handler

Scheduled Pinned Locked Moved Visual Basic
helplinuxquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    reegan41
    wrote on last edited by
    #1

    I have in my application a subroutine that opens a browse folder so that the user can browse to a specific directory, and load that into a text box. The code is like this: ... Set shlShell = New shell32.Shell Set shlFolder = shlShell.BrowseForFolder(Me.hWnd, "Select a Folder", BIF_RETURNONLYFSDIR) textbox_txt.SetFocus textbox_txt.Text = shlFolder.Items.Item.Path 'places path into text box Now, my problem is not when the user browses to a path and clicks OK, that returns the path of the directory fine. What the issue is, when the user clicks CANCEL, I get an error: runtime error '91' Object variable or With block not set. Any ideas on how I should handle this? Thanks. reegan41

    M 1 Reply Last reply
    0
    • R reegan41

      I have in my application a subroutine that opens a browse folder so that the user can browse to a specific directory, and load that into a text box. The code is like this: ... Set shlShell = New shell32.Shell Set shlFolder = shlShell.BrowseForFolder(Me.hWnd, "Select a Folder", BIF_RETURNONLYFSDIR) textbox_txt.SetFocus textbox_txt.Text = shlFolder.Items.Item.Path 'places path into text box Now, my problem is not when the user browses to a path and clicks OK, that returns the path of the directory fine. What the issue is, when the user clicks CANCEL, I get an error: runtime error '91' Object variable or With block not set. Any ideas on how I should handle this? Thanks. reegan41

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Assuming you are using VB.Net You need to test the existence of shlFolder If Not IsNothing(shlFolder) Then process files End If However, you should really be using the .net directory and file info classes to achieve this with a directory browser dialog or openfile dialog!

      Quote from Great Outdoors: its a confident traveller who farts in India

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups