Excel automation: How to access XL sheet as the second task?
When asking, try and imagine the person reading your question doesn't know
what you have, where it is, what you are doing, etc, eg
How to combine that data into one sheet on exit?
In which of the two wb's, or copied sheet into some other (new) wb, on exit
of which wb in which instance, etc
Oh, and not least why?
Regards,
Peter T
"Jack" <replyto@it wrote in message
...
Another question.
When running Excel in the second task.
Initially there are 2 identical spreadsheets.
In one, user may do some changes, in the second my app will log in some
entries.
How to combine that data into one sheet on exit?
Your thoughts appreciated,
Jack
"Jack" <replyto@it wrote in message
...
Hello,
I have a technical problem how to read from XL sheet in the
second
task.
Let assume there is Excel spreadsheet already opened on desktop.
My code:
Public WithEvents moExcelApp As Excel.Application
Public WithEvents moExcel2ndTask As Excel.Application
Set moExcelApp = GetObject(, "Excel.Application")
If moExcelApp Is Nothing Then
Set moExcelApp = CreateObject("Excel.Application")
End If
If moExcelApp Is Nothing Then
Debug.Print "Excel app NOT found!"
ExcelApp = 1: Exit Sub
Else
moExcelApp.EnableEvents = True
Set moExcel2ndTask = CreateObject("Excel.Application")
moExcel2ndTask.EnableEvents = True
End If
==================
In Task Manager I can see the second Excel task running.
But it is not bound to the spreadsheet already opened, like moExcelApp
is.
For example:
moExcel2ndTask.Workbooks.Count returns 0
but
moExcelApp.Workbooks.Count returns 1.
What should be done to bind the second Excel task to the already opened
spreadsheet?
What am I doing wrong?
What I need is to be able to read the cell values in the Excel second
task, while not to disturb user using the sheet in primary task (just to
avoid errors while sheet is in edit mode).
Your thoughts appreciated,
Jack
|