View Full Version : Workbook.Open Opens a Dialogue Box Instead of the Specified file
jasonmelohal
09-17-2014, 08:14 AM
Hello. I am trying to open a file using the code below, but instead of opening the document it opens a dialogue box. Why is it opening a dialogue box instead of the actual file?
Application.OnKey "{F12}", [Workbooks.Open Filename:="C:\Correct File Path\Correct Filename.xlsm"]
Thanks in advance.
Jan Karel Pieterse
09-17-2014, 11:27 PM
Not sure where you got that code, but the correct syntax is:
Workbooks.Open Filename:="C:\Correct File Path\Correct Filename.xlsm"
mancubus
09-18-2014, 01:49 AM
and OnKey method is for running a procedure when a key (or key combination) is pressed.
http://msdn.microsoft.com/en-us/library/office/ff197461(v=office.15).aspx
Sub OpenWB()
Workbooks.Open Filename:="C:\Correct File Path\Correct Filename.xlsm"
End Sub
Sub AssignF12()
Application.OnKey "{F12}", "OpenWB"
End Sub
Sub RestoreF12()
Application.OnKey "{F12}"
End Sub
Sub DisableF12()
Application.OnKey "{F12}", ""
End Sub
jasonmelohal
09-18-2014, 08:11 AM
Thank you!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.