-
Solved: Error Checking against opening file
Ran into a small problem, don't know what is causing it:
I am getting an error: Object Variable not set or With Block not set on the following line:
[VBA]If iStatus Then 'workbook isn't open[/VBA]
[VBA]Sub OpenUpload()
Dim wbU As Workbook
Dim sPath As String
Dim iStatus As Error
sPath = "H:\8-27-06\My Documents\Excel\EC Excel Files\ecboardco uploaded files\"
Err.Clear
On Error Resume Next
Set wbU = Workbooks("Complete_Upload_File.xls")
iStatus = Err
On Error GoTo 0
If iStatus Then 'workbook isn't open
Workbooks.Open sPath & wbU
'Else: wbU.Activate
End If
End Sub[/VBA]
If I run it w/out the error checking the workbook opens fine:
[VBA]
Workbooks.Open sPath & ("Complete_Upload_File.xls")
Set wbU = Workbooks("Complete_Upload_File.xls")
[/VBA]
my site: www.ecboardco.com
was built w/ a majority of the assistance from the board members here... thanks VBAX.
Just because I see something, doesn't mean that what's actually happening is what I see.
You don't get from 0-90 by standing still!
-
[vba]
Sub OpenUpload()
Dim wbU As Workbook
Dim sPath As String
sPath = "H:\8-27-06\My Documents\Excel\EC Excel Files\ecboardco uploaded files\"
On Error Resume Next
Set wbU = Workbooks("Complete_Upload_File.xls")
If Err.Number <> 0 Then 'workbook isn't open
On Error GoTo 0
Workbooks.Open sPath & wbU
'Else: wbU.Activate
End If
End Sub
[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules