Open Excell..

Hi

I have the code as mentioned below and in the picture was workingfine in previous macro. but when i tried to copy the same and useit in differnent macro it throws the error.

compile error: invalid use of new keyword and points to the belowline.

objXL As New Excel.Application

Can any one guide me how to rectify it.

i had properly added the reference too.

SolidworksApi macros
Answers 8
IK
IK 2009-02-04 Best Answer
http://msdn.microsoft.com/en-u.../aa232618(VS.60).aspx

Dim xlApp As Excel.Application
Set xlApp = New [_ExcelApplication]
SF
SF 2009-02-04
hi Ivana,

I am not good in vb, Can you update me where i need to add thoselines.

i just need to open a excell file from ("M:"\D\Solidworks\LP.xls")
IK
IK 2009-02-04
yours: Dim objXL As New Excel.Application

must be:
Dim objXL As Excel.Application
Set objXL = New [_ExcelApplication]
SF
SF 2009-02-04
now it is giving compile error in the next line with sameerror as "invalid use of new keyword "
IK
IK 2009-02-04
And this???

Dim objXL As Excel.Application
Dim objXLRoot As [_ExcelApplication]
Dim objWKB As Excel.Workbook
Set objXLRoot = New [_ExcelApplication]
Set objXL = objXLRoot.Application
objXL.Visible = True

SF
SF 2009-02-04
Thanks, Ivana,

It works well, HOw to make excel to always open with maximizewindow.

Thank you.
IK
IK 2009-02-04
objXL.WindowState = xlMaximized
SF
SF 2009-02-05
thxs for answering. It works great...