Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default path names in getopenfilename

Sub macroopen()
ChDir "\\wxp2000\Joe Docs\Joe\Reports"
Application.GetOpenFilename("Excel,*.xls")
End Sub

how i include the path name in the get file name so that
users dont have to click through all the "layers"

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default path names in getopenfilename

Hi Paul,

You can't change the path in this dialog. It can change only the active
drive or active directory.


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default path names in getopenfilename

Paul,

You can't change the path in the dialog, but I think you already knew that
as you were trying a ChDir before the dialog. This works with local, or
mapped drives, but will not work with a UNC path. That is a bit harder, but
not too hard.

Here is some code that will set the UNC path for you, and GetOpenFileName
will reflect that path.

Private Declare Function SetCurrentDirectoryA Lib "kernel32" _
(ByVal lpPathName As String) As Long

Sub macroopen()
Dim sPath As String

sPath = "\\wxp2000\Joe Docs\Joe\Reports"
If SetUNCPath(sPath) < 0 Then
Application.GetOpenFilename ("Excel,*.xls")
Else
MsgBox "Error in setting the UNC path - " & sPath
End If

End Sub


Function SetUNCPath(sPath As String) As Long
Dim lReturn As Long
lReturn = SetCurrentDirectoryA(sPath)
SetUNCPath = lReturn
End Function


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"tolgag " wrote in message
...
Hi Paul,

You can't change the path in this dialog. It can change only the active
drive or active directory.


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default path names in getopenfilename

Whew I am glad you think thats not to hard!!.I cant quite
make sense of how those two routines fit together.I get a
compile error saying the function or sub is not defined

-----Original Message-----
Paul,

You can't change the path in the dialog, but I think you

already knew that
as you were trying a ChDir before the dialog. This works

with local, or
mapped drives, but will not work with a UNC path. That is

a bit harder, but
not too hard.

Here is some code that will set the UNC path for you, and

GetOpenFileName
will reflect that path.

Private Declare Function SetCurrentDirectoryA

Lib "kernel32" _
(ByVal lpPathName As String) As Long

Sub macroopen()
Dim sPath As String

sPath = "\\wxp2000\Joe Docs\Joe\Reports"
If SetUNCPath(sPath) < 0 Then
Application.GetOpenFilename ("Excel,*.xls")
Else
MsgBox "Error in setting the UNC path - " & sPath
End If

End Sub


Function SetUNCPath(sPath As String) As Long
Dim lReturn As Long
lReturn = SetCurrentDirectoryA(sPath)
SetUNCPath = lReturn
End Function


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"tolgag " wrote

in message
...
Hi Paul,

You can't change the path in this dialog. It can change

only the active
drive or active directory.


---
Message posted from http://www.ExcelForum.com/



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default path names in getopenfilename

Hi again Paul,

Sub macroopen()
Dim sPath As String
Dim sFile

sPath = "\\wxp2000\Joe Docs\Joe\Reports"
If SetUNCPath(sPath) = 0 Then
MsgBox "Error in setting the UNC path - " & sPath
Else
sFile = Application.GetOpenFilename("Excel,*.xls")
If sFile < False Then
Workbooks.Open Filename:=sFile
End If
End If

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Paul" wrote in message
...
Bob ..one small oversight.Having found the file i now need
to open it! <vbg????
-----Original Message-----
Thank god! I was running out of ideas. Told you it was

not too hard <vbg

Enjoy your next project.

Regards

Bob

"Paul" wrote in message
...
Bob it works like a charm.Now to go back to my new vba
book by reed jacobsen..Hopefully my next project will be
covered by it!!Thanks for your help!



.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default path names in getopenfilename

you are a legend bob!
-----Original Message-----
Hi again Paul,

Sub macroopen()
Dim sPath As String
Dim sFile

sPath = "\\wxp2000\Joe Docs\Joe\Reports"
If SetUNCPath(sPath) = 0 Then
MsgBox "Error in setting the UNC path - " & sPath
Else
sFile = Application.GetOpenFilename("Excel,*.xls")
If sFile < False Then
Workbooks.Open Filename:=sFile
End If
End If

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Paul" wrote in message
...
Bob ..one small oversight.Having found the file i now

need
to open it! <vbg????
-----Original Message-----
Thank god! I was running out of ideas. Told you it was

not too hard <vbg

Enjoy your next project.

Regards

Bob

"Paul" wrote in

message
...
Bob it works like a charm.Now to go back to my new

vba
book by reed jacobsen..Hopefully my next project

will be
covered by it!!Thanks for your help!



.



.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default path names in getopenfilename

Why thank-you sir. If I could only convince my family<vbg!

Bob

"paul" wrote in message
...
you are a legend bob!



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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Names of workbooks - want relative, with no Full Path Gdareos[_2_] New Users to Excel 1 April 21st 08 12:08 AM
Advice long path names in formulas.... tim m Excel Worksheet Functions 1 July 6th 06 09:40 PM
Indirect and Path & File Names Anthony Slater Excel Discussion (Misc queries) 3 April 29th 05 03:38 PM
Recurring Problems with Links with Full Path Names JMcBeth Excel Discussion (Misc queries) 1 February 4th 05 10:11 PM
GetopenFilename default path Srinath Excel Programming 5 October 10th 03 04:47 PM


All times are GMT +1. The time now is 07:54 AM.

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

About Us

"It's about Microsoft Excel"