Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default MUST BE POSSIBLE !! ..........

....I want to use the GetOpenFile method to set a variable that is an
excel file i.e:

MyAllocPathway = Application.GetOpenFilename("Excel Files (*.xls),
*.xls, Add- in Files (*.xla), *.xla", 1, "Select Excel you wish to
attach")

this works ok

Is it possible so that whenever this is actioned it opens with the
contents of a specific folder?

I've tried putting this infront of the above line, but itdoesn't seem
to work:

ChDir ("I:\Fin\Val data\OLA\OLAB figures (Weekly)\")

Any help greatly appreciated,
Jason
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default MUST BE POSSIBLE !! ..........

You are changing the deafult directory on the I drive but are no
switching to that drive- You also don't need the brackets unless yo
are assiging it to a variable.

Duncan

chdrive "I"
chdir "I:\Fin\Val data\OLA\OLAB figures (Weekly)\

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default MUST BE POSSIBLE !! ..........

Jason,

It should work if you use ChDir prior to calling GetOpenFilename.
You may need to use ChDrive to change the drive. E.g,

ChDrive "I:"
ChDir "I:\Fin\Val data\OLA\OLAB figures (Weekly)\"
MyAllocPathway = Application.GetOpenFilename("Excel Files
(*.xls),
*.xls, Add- in Files (*.xla), *.xla", 1, "Select Excel you wish
to
attach")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"jason" wrote in message
om...
...I want to use the GetOpenFile method to set a variable that

is an
excel file i.e:

MyAllocPathway = Application.GetOpenFilename("Excel Files

(*.xls),
*.xls, Add- in Files (*.xla), *.xla", 1, "Select Excel you wish

to
attach")

this works ok

Is it possible so that whenever this is actioned it opens with

the
contents of a specific folder?

I've tried putting this infront of the above line, but

itdoesn't seem
to work:

ChDir ("I:\Fin\Val data\OLA\OLAB figures (Weekly)\")

Any help greatly appreciated,
Jason



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default MUST BE POSSIBLE !! ..........

Hi Jason

Here is a example that is also using ChDrive

Sub test()
Dim SaveDriveDir As String, MyPath As String
Dim FName As Variant

SaveDriveDir = CurDir
MyPath = "C:\Data"
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:="Excel Files, *.xls")

If FName = False Then
'do nothing
Else
'your code
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"jason" wrote in message om...
...I want to use the GetOpenFile method to set a variable that is an
excel file i.e:

MyAllocPathway = Application.GetOpenFilename("Excel Files (*.xls),
*.xls, Add- in Files (*.xla), *.xla", 1, "Select Excel you wish to
attach")

this works ok

Is it possible so that whenever this is actioned it opens with the
contents of a specific folder?

I've tried putting this infront of the above line, but itdoesn't seem
to work:

ChDir ("I:\Fin\Val data\OLA\OLAB figures (Weekly)\")

Any help greatly appreciated,
Jason



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default MUST BE POSSIBLE !! ..........

Thanks to everybody for help
(Like the little touch of restoring initial settings at the end of your routine Ron)

thanks again
jason



"Ron de Bruin" wrote in message ...
Hi Jason

Here is a example that is also using ChDrive

Sub test()
Dim SaveDriveDir As String, MyPath As String
Dim FName As Variant

SaveDriveDir = CurDir
MyPath = "C:\Data"
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:="Excel Files, *.xls")

If FName = False Then
'do nothing
Else
'your code
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"jason" wrote in message om...
...I want to use the GetOpenFile method to set a variable that is an
excel file i.e:

MyAllocPathway = Application.GetOpenFilename("Excel Files (*.xls),
*.xls, Add- in Files (*.xla), *.xla", 1, "Select Excel you wish to
attach")

this works ok

Is it possible so that whenever this is actioned it opens with the
contents of a specific folder?

I've tried putting this infront of the above line, but itdoesn't seem
to work:

ChDir ("I:\Fin\Val data\OLA\OLAB figures (Weekly)\")

Any help greatly appreciated,
Jason

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 08:51 PM.

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"