Open File Automatically

michaelp1029

Board Regular
Joined
Jul 15, 2008
Messages
63
So here's what i want to do. I want to press a button so that it automatically opens up the file "NYSEG-RG&E-NGrid Profile Pricing Automated.xls" from the "N:\Group\Gateway\McCarthy's Sausage Factory" folder. Here's what I got and it ain't working. Help?

Sub FindPrices()
Dim wbResults As Workbook

With Application.FileSearch
.NewSearch
.LookIn = "N:\Group\Gateway\McCarthy's Sausage Factory"
.FileType = msoFileTypeExcelWorkbooks
.Filename = "NYSEG-RG&E-NGrid Profile Pricing Automated.xls"
If .Execute > 0 Then 'Workbooks in folder
Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)
Else
MsgBox "File Does Not Exist"
End If
End With
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try this code. User Ctrl+K to open the file automatically.

Code:
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+k
'
    Workbooks.Open Filename:="N:\Group\Gateway\McCarthy's Sausage Factory\NYSEG-RG&E-NGrid Profile Pricing Automated.xls"
End Sub
 
Upvote 0
Try this code. User Ctrl+K to open the file automatically.

Code:
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+k
'
    Workbooks.Open Filename:="N:\Group\Gateway\McCarthy's Sausage Factory\NYSEG-RG&E-NGrid Profile Pricing Automated.xls"
End Sub

If you just copy and paste, how will Excel know the shortcut key?
 
Upvote 0
If you just copy and paste, how will Excel know the shortcut key?

You have to go in and instantiate the shortcut manually.

Also note that opening the workbook should be easily recordable, unless your path changes...

HTH,
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,852
Members
449,096
Latest member
Erald

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