I have a main "front end" workbook that people will be opening to interact
with. Whenever this main workbook opens, I would like it to open another
"data" workbook in the BACKGROUND, so I can copy data back and forth between
them using various scripts. I don't want the front end user to be able to
see the data sheet, or (ideally) even know that it has been opened in the
background.
In the code for "ThisWorkbook" in the main front end workbook, I have:
Dim objApp As Excel.Application
Private Sub Workbook_Open()
Set objApp = CreateObject("Excel.Application")
objApp.Workbooks.Open ("X:\pathto\Data.xls")
objApp.Visible = False
End Sub
In the code for the main worksheet in the main front end workbook, I have:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim DataSheet As Worksheet
Set DataSheet = objApp.Workbooks("Data.xls").Sheets(1)
[.....]
End Sub
So, with the code as I have shown above, I usually get an "Object
Expected" error on my Set Datasheet line, which makes me think it isn't
recognizing my public objApp variable that I declared in the code for
ThisWorkbook. Should I be declaring it differently?
If I simply remove the "objApp." prefix in that line, of course it says
subscript out of range. If I use a regular Worksheets.Open (instead of
creating a new app object), it brings the Data.xls workbook to the
foreground and I can't figure out how to hide it.... I want the opening of
the Data workbook to be stealthy and hidden, if that is at all possible....
Any help at all would be most appreciated. Thanks,
---G
Bookmarks