Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 626
- Office Version
- 365
- 2010
- Platform
- Windows
I am not sure why this code does not worked because I used a similar variation in another project and it worked. I checked the file location of the file and path needing to be opened and its correct. Not sure why its not finding the workbook. The error occurs on the
Here's the rest of the code. Thank you.
Code:
Set wb = Workbooks.Open(sFile)
Code:
Option Explicit
'Declares variable names
Dim sPath As String, sFile As String
Dim wb As Workbook
Dim ws As Worksheet
Private Sub Workbook_Open()
'Declares variable names
Dim ans As String
Dim ansSplit As String
Dim i As Integer
sPath = "C:\Users\Desktop\Bulk_Yield_Report\"
sFile = sPath & "F-103-04 Exh E-Bulk MT-Pkg Prod Theoretical Yield Report-Rev004.xls"
Set wb = Workbooks.Open(sFile)
ans = MsgBox("Is this a split Lot?", vbQuestion + vbYesNo, "Split Lot")
If ans = vbNo Then
frmPackageYield.Show vbModeless
Else
ansSplit = InputBox("How many times does this lot split?", "Split Lot")
For i = 1 To ansSplit
frmPackageYield.Show 'vbModeless
Next i
'NEEDS CODING HERE
End If
Call ClearContents
End Sub