Trouble with open workbook code.

B

Brian

For some reason this code does not open the Workbook. It worked when it was
in the Userform Code window. What did I do wrong?

'*******************************************************
'Open New Engineer Spec 8 Control Button
'Located in M2_Open_New_Workbook
'*******************************************************
Private Sub Open_New_Engineer_Spec_8_Click()
Call Open_New_Engineer_Spec
End Sub


Declarations
-------------------------
Dim myMsg As String



Module Code
----------------------------------------------------------
'Open New Master Engineering Spec Control Button
Sub Open_New_Engineer_Spec()

On Error Resume Next

Workbooks.Open ("Master Engineering Spec.xlsm")

If Err.Number <> 0 Then

MsgBox prompt:=UserForm1.Engineer_2.Value & vbLf & "Your Open Method
Failed, No Engineering Spec was Opened", _
Title:="C.E.S."

MsgBox "The Open Method Failed, Engineering Spec was not Opened", ,
"C.E.S."

End If

End Sub
 
J

Jacob Skaria

Try with the full path of the workbook instead

Workbooks.Open ("c:\Master Engineering Spec.xlsm")
 
B

Brian

The path is a varible. So I can not specify the full path. it worked before I
moved it to a module.
 
J

Jacob Skaria

If the path is same as the active workbook path then change the code to

Workbooks.Open (ActiveWorkbook.Path & "\Master Engineering Spec.xlsm")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top