Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 140
  • Last Modified:

Problem selecting folder in Visual Basic

Hi!, I´m trying to select a folder using FolderItem object with this code:

    Dim myShell As New Shell
    Dim FoldItem As FolderItem
    Dim l1 As Long
    Dim l2 As Long
    Set FoldItem = myShell.BrowseForFolder(l1, "Select Folder", l2)
   
    TextDirOrigen = FoldItem.Path   'Just to show the folder path



The problem is when I execute the program and I select the folder the error message is:
"types doesn´t match"
0
saller
Asked:
saller
  • 2
  • 2
1 Solution
 
sallerAuthor Commented:
Is urgent...
0
 
aelatikCommented:
Dim a As New Shell
 Dim f As Folder
 Dim fi As FolderItem
 Set f = a.BrowseForFolder(Me.hWnd, "Browse", 0)
 Set fi = f.Items.Item
 MsgBox fi.Path
0
 
emadatCommented:
Dim myShell As New Shell
Dim objFolder As Folder
Dim objFolderItem As FolderItem
Dim TextDirOrigen
    Set objFolder = myShell.BrowseForFolder(Me.hWnd, "Select Folder", 0)
    Set objFolderItem = objFolder.Items.Item(0)
    TextDirOrigen = objFolderItem.Path   'Just to show the folder path
0
 
aelatikCommented:
In your case this would be...

   Dim myShell As New Shell
   Dim Fold As Folder
   Dim FoldItem As FolderItem
   Dim l1 As Long
   Dim l2 As Long
   Set Fold = myShell.BrowseForFolder(Me.hWnd, "Select Folder", l2)
   Set FoldItem = Fold.Items.Item
   TextDirOrigen = FoldItem.Path   'Just to show the folder path
0
 
sallerAuthor Commented:
Solved!!!!!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now