Messing around in Excell

Heya fella's !
I hope all is well ? nearly weekend !

We have an excelsheet here @ work with a vba macro in it.
The macro asks the user some info, and depending on that info,prints out the excelsheet. Its a bit of an order-leaflet thing.

I'm done writing a macro that automises drawings and assembliesdepending on users inputs and selections. Now i was thinking icould append the excel macro to my SW macro and have thatexcelsheet made in one go.

So, i've added the vba from the excel to my macro in SW.
So far so good.

here is a snippet of how the vba inside the excelsheet looked like.

 

ActiveSheet.Range("aa1").Select
ActiveCell = deursoort
Sheets("Blad1").Select
ActiveSheet.Range("A5").Select
ActiveCell.FormulaR1C1 = "DRAAIDEUR"
breedte = nub
ActiveSheet.Range("e5").Select
ActiveCell.FormulaR1C1 = breedte
lengte = nuh
ActiveSheet.Range("g5").Select
ActiveCell.FormulaR1C1 = lengte
aantal = 1
etc

Because my starting position is no longer Excel in itself,but i'm in SolidWorks, I had to get a handle on Excell and open theexcellsheet first. I did this as follows :

 


' Launch and attach to the Excel API
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = True
XLApp.Workbooks.Open filename:= _
"L:\CAD\Isotools\Uitschrijven deuren 2009.xls"

that works great !
Just had to re-arange te excelsheet vba to read like this now :

 

XLApp.ActiveSheet.Range("aa1").Select
XLApp.ActiveCell = deursoort
XLApp.Sheets("Blad1").Select
XLApp.ActiveSheet.Range("A5").Select
XLApp.ActiveCell.FormulaR1C1 = "DRAAIDEUR"
breedte = nub
XLApp.ActiveSheet.Range("e5").Select
XLApp.ActiveCell.FormulaR1C1 = breedte
lengte = nuh
XLApp.ActiveSheet.Range("g5").Select
XLApp.ActiveCell.FormulaR1C1 = lengte
aantal = 1
etc

'adding the 'XLApp.' where needed.

Whats the problem then ?
This original excel vba changes linethickness of selected cells :

 


Range.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With

I placed 'XLApp.' in front of 'Range' on the first line, thatworks well.
When going over the second line, i get an error, "Object required".
obviously it doesn't now how to handle 'Selection' ? I've triedsetting it to 'XLApp.Selection' but that gives me another error ,"Object doesn't support this property or method".

Any idea how i could get 'Selection' to work ?

Cheers,
Bert



SolidworksApi macros