Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"