Macro copiar y pegar ruta de Archivo en celda
Tengo una macro que me deja elegir una carpeta y me muestra su ruta en un MsgBox, pero también necesito que copie esa ruta y me la pegue en una celda.Es algo sencillo pero se me ha dificultado un pocoEste es el códigoPrivate Type BROWSEINFO ' used by the function GetFolderNamehOwner As LongpidlRoot As LongpszDisplayName As StringlpszTitle As StringulFlags As Longlpfn As LonglParam As LongiImage As LongEnd TypePrivate Declare Function SHGetPathFromIDList Lib "shell32.dll" _Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As LongPrivate Declare Function SHBrowseForFolder Lib "shell32.dll" _Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As LongFunction GetFolderName(Msg As String) As String' returns the name of the folder selected by the userDim bInfo As BROWSEINFO, path As String, r As LongDim X As Long, pos As IntegerbInfo.pidlRoot = 0& ' Root folder = DesktopIf IsMissing(Msg) ThenbInfo.lpszTitle = "Selecciona una carpeta"' the dialog titleElsebInfo.lpszTitle = Msg ' the dialog titleEnd IfbInfo.ulFlags = &H1 ' Type of directory to returnX = SHBrowseForFolder(bInfo) ' display the dialog' Parse the resultpath = Space$(512)r = SHGetPathFromIDList(ByVal X, ByVal path)If r Thenpos = InStr(path, Chr$(0))GetFolderName = Left(path, pos - 1)ElseGetFolderName = ""End IfEnd FunctionSub TestGetFolderName()Dim FolderName As StringFolderName = GetFolderName("Selecciona una carpeta")If FolderName = "" ThenMsgBox "No has seleccionado ninguna carpeta"ElseMsgBox "Haz seleccionado la carpeta: " & FolderName Range("A1").Value = FolderNameEnd IfEnd Sub
by http://www.todoexpertos.com/categorias/tecnologia-e-internet/software-y-aplicaciones/microsoft-excel/respuestas/2370398/macro-copiar-y-pegar-ruta-de-carpeta-en-celda
Yo necesito genere la ruta de un archivo (ppt en este caso)
No he podido modificar la macro :-(
Bueno, es exactamente lo que yo necesitaba. Gracias !!!!!!! - Edison Tiglla
"Range("A5") = carpeta" se debe cambiar por: Range("A5").value = carpeta - David Plaza
Gracias Dante¡ - David Plaza
:) - Dante Amor