[RESOLVED] Code to Check if Workbook Exists
I have (in Excel) code similar to this:
Code:
Public Sub One()
Dim varStar
Dim varStars
varStar = Array("Rain", "Sleet", "Snow")
For each varStar in varStars
Call Precipitation (varStar)
Call Monthly (varStar)
Call Weekly (varStar)
Call Yearly (varStar)
Next varStar
End Sub
Public Sub Monthly (varStar)
On Error Resume Next
Set WB = Workbooks.Open(Filename:="" & varStar)
Run "RefreshOnOpen"
With WB
WB.SaveAs Filename:=""
End With
WB.Close
On Error GoTo 0
End Sub
And then from there it will call the corresponding module and pass varStar to each module and run the code. The issue I have is that sometimes (like right now) it is a new year, or a new month and varStar may not exist in the specific workbook. How can I code it to, if varStar doesn't exist just skip it and keep going. I tried On Error Resume Next, and On Error GoTo 0. But that wasn't 100% efficient. If you need to see additional coding, let me know, and I can provide more.
Re: Code to Check if Workbook Exists
Greetings, this forum is for VB.NET issues which include Office automation but not for VBA issues. The correct forum is here http://www.vbforums.com/forumdisplay.php?f=37
Re: Code to Check if Workbook Exists
Oh, thanks for the info! I re posted my question there!
here to be exact
http://www.vbforums.com/showthread.p...57#post4118557