Trouble with open workbook code.

  • Thread starter Thread starter Brian
  • Start date Start date
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
 
Try with the full path of the workbook instead

Workbooks.Open ("c:\Master Engineering Spec.xlsm")
 
The path is a varible. So I can not specify the full path. it worked before I
moved it to a module.
 
If the path is same as the active workbook path then change the code to

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