Open File Dialog - Specified path

StringKing

New Member
Joined
Jul 22, 2009
Messages
21
I have a MAIN workbook and i also recieve daily data (in Excel format) that needs to be added to this Main workbook. This daily file is saved in a specific network folder.

I'm looking for VBA to open the "Workbook Open" dialog box on a specified network path by default and to allow the user to then select an Excel file from this folder to open when selected, whereafter the rest of the macro will continue to run.
The folder (network path) will never change. The "addition" will happen daily.
I have the rest of the macro sorted, i am just battling to open the "Open Workbook" dialog on a specified default path.

Thanks for the help! :confused:
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Have you tried using ChDrive and/or ChDir to set the current directory/path before displaying the dialog?
 
Upvote 0
Hi Norie,
Thanks for responding to my issue. Yes i have tried that. A million options are rushing through my head, so i'll give it one more go....
 
Upvote 0
Is the folder you want to goto on a network/mapped drive?
 
Upvote 0
Forgot to ask, how are you displaying the dialog?
 
Upvote 0
The folder is a network drive.

The dialog is in the same way than the window that opens when you press Ctrl+O .

Hope this answers your questions.
 
Upvote 0
I thought you were using code to open the dialog.:eek:
 
Upvote 0
Yes, I am using code. I was just explaining what window must open (how the dialog must display).
Anyway.... I have the code sorted, and it works a charm.

Here it is:

Sub Get_Data()

ChDir "X:\Network\Folder\Location"

FileToOpen = Application.GetOpenFilename _
(Title:="Select file to import", _
FileFilter:="Excel Files *.xlsx (*.xlsx),")
''
If FileToOpen = False Then
MsgBox "No file specified.", vbExclamation, "ERROR"
Exit Sub
Else
Workbooks.Open Filename:=FileToOpen
End If
End Sub

"If posting code please use code tags." <--- Not sure how this works... :confused:

That's it...
 
Upvote 0
For interest sake:
I have noticed that the code does not open to the specified folder today.

I have added the following code before the "CHDIR..."

Call ChDrive("X")
Call ChDir("X:\Network\Folder\Location")

It now shows the specified location.

;)
 
Upvote 0

Forum statistics

Threads
1,213,558
Messages
6,114,296
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top