Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetOpenPathname???
Dear all
With GetOpenFilename() I can start the "open"-Window to find a file and return a file name with its path. I only want to return a path without a file name. Is there an equal way to do it. I somehow remember that I saw a command but I cannot remember it. Something like GetOpenPathname. Thanks Philipp |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetOpenPathname???
Use the Path property.
msgBox "The path is" & Path If you need the last \, you need to add it to the string msgBox "The path is" & Path &"\" Lars Kofod -----Original Message----- Dear all With GetOpenFilename() I can start the "open"-Window to find a file and return a file name with its path. I only want to return a path without a file name. Is there an equal way to do it. I somehow remember that I saw a command but I cannot remember it. Something like GetOpenPathname. Thanks Philipp . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetOpenPathname???
Sorry Phillip
It needs to be Application.Path Lars Kofod -----Original Message----- Dear all With GetOpenFilename() I can start the "open"-Window to find a file and return a file name with its path. I only want to return a path without a file name. Is there an equal way to do it. I somehow remember that I saw a command but I cannot remember it. Something like GetOpenPathname. Thanks Philipp . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetOpenPathname???
Sometimes I can be so stupid.
This works ActiveWorkbook.Path Lars Kofod -----Original Message----- Dear all With GetOpenFilename() I can start the "open"-Window to find a file and return a file name with its path. I only want to return a path without a file name. Is there an equal way to do it. I somehow remember that I saw a command but I cannot remember it. Something like GetOpenPathname. Thanks Philipp . |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetOpenPathname???
Phillipp,
Below is some code by, I think, Jim Rech, that will display a "Browse For Folder" dialog box. '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''' ''' Public Const BIF_RETURNONLYFSDIRS As Long = &H1 Public Const BIF_DONTGOBELOWDOMAIN As Long = &H2 Public Const BIF_RETURNFSANCESTORS As Long = &H8 Public Const BIF_BROWSEFORCOMPUTER As Long = &H1000 Public Const BIF_BROWSEFORPRINTER As Long = &H2000 Public Const BIF_BROWSEINCLUDEFILES As Long = &H4000 Public 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 szBrowseFolder() As String Const szINSTRUCTIONS As String = "Choose the folder to use for this operation." & vbNullChar Dim uBrowseInfo As BROWSEINFO Dim szBuffer As String Dim lID As Long Dim lRet As Long With uBrowseInfo .hOwner = 0 .pidlRoot = 0 .pszDisplayName = String$(MAX_PATH, vbNullChar) .lpszINSTRUCTIONS = szINSTRUCTIONS .ulFlags = BIF_RETURNONLYFSDIRS ' + BIF_USENEWUI .lpfn = 0 End With szBuffer = String$(MAX_PATH, vbNullChar) ''' Show the browse dialog. lID = SHBrowseForFolderA(uBrowseInfo) If lID Then ''' Retrieve the path string. lRet = SHGetPathFromIDListA(lID, szBuffer) If lRet Then szBrowseFolder = Left$(szBuffer, InStr(szBuffer, _ vbNullChar) - 1) End If End Function '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''' ''' Sub AAA_Test() Dim FolderName As String FolderName = szBrowseFolder() MsgBox FolderName End Sub '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''' ''' -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Philipp Schramek" wrote in message ... Dear all With GetOpenFilename() I can start the "open"-Window to find a file and return a file name with its path. I only want to return a path without a file name. Is there an equal way to do it. I somehow remember that I saw a command but I cannot remember it. Something like GetOpenPathname. Thanks Philipp |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetOpenPathname???
See John Walkenbach's site for sample code:
http://j-walk.com/ss/excel/tips/tip29.htm Selecting a Directory -- Regards, Tom Ogilvy "Philipp Schramek" wrote in message ... Dear all With GetOpenFilename() I can start the "open"-Window to find a file and return a file name with its path. I only want to return a path without a file name. Is there an equal way to do it. I somehow remember that I saw a command but I cannot remember it. Something like GetOpenPathname. Thanks Philipp |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|