0

Not sure how many people know about WinWrap Basic language which supports the .Net framework. But that is where my problem is. Hoping someone out there know about the language.

I am using it to communicate with Excel 2010. Basically I am extracting data for a proprietary data format and spitting it out to Excel. The following execute perfectly when no additional instances of Microsoft Excel 2010 are active during script run.

xExcel = CreateObject("Excel.Application") 
xBook = xExcel.Workbooks.Open(XLFilePath) 
xSheet = xBook.Worksheets(“Sheet1”) 
xExcel.Visible = False 
xSheet.Cells(1,1).Value = "Study Name"

However, if an additional Excel 2010 instance is activated manually by the user during the following script run, script errors out.

xExcel = CreateObject("Excel.Application") 
xBook = xExcel.Workbooks.Open(XLFilePath) 
xSheet = xBook.Worksheets(“Sheet1”) 
xExcel.Visible = False     
Do 
  xSheet.Cells(1,1).Value = "Study Name" 
Loop

The guys at WinWrap say that CreateObject() in WinWrap is a simple code that calls the CoCreateInstance API. I am sort of lost there. Can someone help me understand how create multiple Excel instances.

Edit I get the Runtime 50290 Application Specific Error.

K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43
RahulD
  • 1
  • 1
  • You should make mention what kind of error occurs in what line of the code. And why the infinite loop in second code sample? Maybe this is the reason of the error? – Axel Richter Apr 01 '15 at 05:15
  • No the infinite loop is just to simulate my script running over an extended period of time doing different things, while someone would operate Excel manually. I dont actually have an infinite loop in my code. I get Runtime 50290 Application Specific Error. – RahulD Apr 01 '15 at 22:47

1 Answers1

0

Have you tried GetObject?

Dim objExcel As Object
 On Error Resume Next
 Set objExcel = GetObject(, "Excel.Application")
With objExcel
    'do something
End With
Jordan
  • 148
  • 1
  • 11