OpenFileDialog + almacenar ruta?

Iniciado por SuperDraco, 13 Julio 2011, 17:04 PM

0 Miembros y 1 Visitante están viendo este tema.

SuperDraco

Hola, lo que intento es abrir el dialogo de windows para abrir una carpeta, solo abrirla y guardar la carpeta que quiero, por ejemplo, abro el menú y voy a la carpeta "C:\Test" y luego le doy a "ok" en el menu, y esa carpeta se guarda en una variable...


solo tengo echo esto, y no funciona.


Código (vb) [Seleccionar]
Private Sub Opendir_Click()
    Dim opendir As Long, Nombre As String
    Dim sFile As String
    opendir = FreeFile
       'sFile almacenará el path completo que nos interesa
       sFile = Abrir
       'Comprobamos que no sea una cadena vacia
       If sFile <> "" Then
      Savefile = FreeFile
       End If
End Sub
No he vuelto, solo estoy de paso.

raul338


SuperDraco

gracias tio

lo he solucionado escribiendo esto en un módulo, y luego llamandolo al hacer "click" en la opción  :xD

que novato soy xD solo se crear el menú



Código (vb) [Seleccionar]
Private Const BIF_RETURNONLYFSDIRS As Long = &H1
Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
Private Const BIF_RETURNFSANCESTORS As Long = &H8
Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
Private Const BIF_BROWSEFORPRINTER As Long = &H2000
Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
Private Const MAX_PATH As Long = 260

Type BrowseInfo
   hOwner As Long
   pidlRoot As Long
   pszDisplayName As String
   lpszINSTRUCTIONS As String
   ulFlags As Long
   lpfn As Long
   lParam As Long
   iImage As Long
End Type

Type SHFILEOPSTRUCT
   hwnd As Long
   wFunc As Long
   pFrom As String
   pTo As String
   fFlags As Integer
   fAnyOperationsAborted As Boolean
   hNameMappings As Long
   lpszProgressTitle As String
End Type

Declare Function SHGetPathFromIDListA Lib "shell32.dll" ( _
   ByVal pidl As Long, _
   ByVal pszBuffer As String) As Long

Declare Function SHBrowseForFolderA Lib "shell32.dll" ( _
   lpBrowseInfo As BrowseInfo) As Long


Function BrowseFolder(Optional Caption As String = "") As String

Dim BrowseInfo As BrowseInfo
Dim FolderName As String
Dim ID As Long
Dim Res As Long

With BrowseInfo
  .hOwner = 0
  .pidlRoot = 0
  .pszDisplayName = String$(MAX_PATH, vbNullChar)
  .lpszINSTRUCTIONS = Caption
  .ulFlags = BIF_RETURNONLYFSDIRS
  .lpfn = 0
End With

FolderName = String$(MAX_PATH, vbNullChar)
ID = SHBrowseForFolderA(BrowseInfo)
If ID Then
  Res = SHGetPathFromIDListA(ID, FolderName)
  If Res Then
      BrowseFolder = Left$(FolderName, InStr(FolderName,vbNullChar) - 1)
  End If
End If

End Function
No he vuelto, solo estoy de paso.