Kalechibki
Programmer
After running some queries, my current graphing macros call an excel workbook(Because of the size and scope, I couldn't get Access to cooperate, and I'm much more familiar with Excel). Well, now that I'm done making sure that the graphs work, I'm trying to have it so that it doesn't open the workbook again if it's already opened. While using the following loop, which I used a very similar one before when trying to find out if Word Documents are open while in Excel, I noticed that it was still opening the workbook, and not seeming to even check if it was open.
Dim xlapp As Object
Set xlapp = CreateObject("Excel.Application"
For Each book In xlapp.Application.Workbooks
If InStr(1, book.Name, "ChartCreator", 1) Then
docFound = True
book.Activate
Exit For
Else
docFound = False
End If
Next book
Upon further inspection (by going line by line) I noticed that it hits the first line, but then skips the entire loop and just goes on (the next line is if docFound is false, open the workbook). I've found this perplexing especially since there are currently 3 workbooks open on my computer.
Anyone have any ideas why it would skipping these?
Dim xlapp As Object
Set xlapp = CreateObject("Excel.Application"
For Each book In xlapp.Application.Workbooks
If InStr(1, book.Name, "ChartCreator", 1) Then
docFound = True
book.Activate
Exit For
Else
docFound = False
End If
Next book
Upon further inspection (by going line by line) I noticed that it hits the first line, but then skips the entire loop and just goes on (the next line is if docFound is false, open the workbook). I've found this perplexing especially since there are currently 3 workbooks open on my computer.
Anyone have any ideas why it would skipping these?