My Workbook is always hidden when I open it?
I still think that you were hiding any errors by using "on error resume next".
On error resume next
tells excel/vba to ignore any error that happens.
So this is not something you want to turn on and leave on. Turn it on, do the
thing that you know may cause the error and turn it off.
And to turn it off, you can tell excel/vba to handle any error that occurs by
using "on error goto 0".
DDawson wrote:
Thanks Dave, you got it to work for me!
I simply had to amend the path names.
If you've got another moment:
I wonder what went wrong in my other version?
What does On Error GoTo 0 do?
Thanks again
from Dylan
"Dave Peterson" wrote:
You're using a variable named wbk4. That looks like an error.
I'd do something like:
Option Explicit
Private Sub Workbook_Open()
Dim wbk1 As Workbook
Dim wbk2 As Workbook
Set wbk1 = Nothing
Set wbk2 = Nothing
On Error Resume Next
Set wbk1 = Workbooks("Export_Requests.csv")
Set wbk2 = Workbooks("Project Summary.xls")
On Error GoTo 0
If wbk1 Is Nothing Then
On Error GoTo 0
Set wbk1 = Workbooks.Open _
("I:\A&T Contracts\000 Utilities\Project " _
& "Specific\Contract Docs\Integrated Utility Services\" _
& "Export_Requests.csv")
On Error GoTo 0
If wbk1 Is Nothing Then
MsgBox "wbk1 didn't open!"
Exit Sub
End If
wbk1.Windows(1).Visible = False
End If
If wbk2 Is Nothing Then
On Error Resume Next
Set wbk2 = Workbooks.Open _
("I:\A&T Contracts\000 Utilities\Project " _
& "Specific\Contract Docs\Integrated Utility Services\" _
& "Option E\Payment\Project Summary.xls ")
On Error GoTo 0
If wbk2 Is Nothing Then
MsgBox "wbk2 didn't open!"
Exit Sub
End If
wbk2.Windows(1).Visible = False
End If
End Sub
Untested, but it did compile.
Ps. Check the path names. I put them on separate lines to avoid line wrapping
problems, but the spaces may not be right!
--
Dave Peterson
|