krywarick6
Automotive
- Jun 9, 2003
- 138
In my feable attempts to open Excel from SolidWorks, I have tried to mirror some previous code and it works to an extent.
This code was written from Excel to open SolidWorks. It opens SolidWorks and then a given document. Assume variables have been named and defined.
‘Opens SolidWorks
Set swApp = CreateObject("SldWorks.Application")
swApp.Visible = True
Set Part = swApp.ActiveDoc
‘ Load model and expand window
Set Part = swApp.OpenDoc("folder location\file.SLDPRT", 1)
Set Part = swApp.ActivateDoc("Pulley.SLDPRT")
swApp.ActiveDoc.ActiveView.FrameLeft = 0
swApp.ActiveDoc.ActiveView.FrameTop = 0
swApp.ActiveDoc.ActiveView.FrameState = 1
swApp.ActiveDoc.ActiveView.FrameState = 1
========
What I want to achieve is the same things, but from the reverse direction. I want to open Excel from SolidWorks.
Set ExSheet = CreateObject("Excel.Sheet")
ExSheet.Application.Visible = True
Set exDoc = ExSheet.ActiveDoc
' Load Excel and expand window
Set exDoc = ExSheet.OpenDoc("folder location\file.xls", 1)
Set exDoc = ExSheet.ActivateDoc("Pulley.SLDPRT")
ExSheet.ActiveDoc.ActiveView.FrameLeft = 0
ExSheet.ActiveDoc.ActiveView.FrameTop = 0
ExSheet.ActiveDoc.ActiveView.FrameState = 1
ExSheet.ActiveDoc.ActiveView.FrameState = 1
I’m getting lost at the point where Excel opens. It opens Excel and a sheet, but stops at the bold text line. The debugger message box opens and displays “Object doesn’t support this method or property”. I believe that I’m using the wrong syntax to keep going in Excel so I can’t even tell if the rest would be correct.
Any suggestions? My API experience is very basic. I’m a cutter and paster from examples and try to get them to work. So anything would help.
Christopher Zona - Senior CAD Designer
Concord, Ontario
This code was written from Excel to open SolidWorks. It opens SolidWorks and then a given document. Assume variables have been named and defined.
‘Opens SolidWorks
Set swApp = CreateObject("SldWorks.Application")
swApp.Visible = True
Set Part = swApp.ActiveDoc
‘ Load model and expand window
Set Part = swApp.OpenDoc("folder location\file.SLDPRT", 1)
Set Part = swApp.ActivateDoc("Pulley.SLDPRT")
swApp.ActiveDoc.ActiveView.FrameLeft = 0
swApp.ActiveDoc.ActiveView.FrameTop = 0
swApp.ActiveDoc.ActiveView.FrameState = 1
swApp.ActiveDoc.ActiveView.FrameState = 1
========
What I want to achieve is the same things, but from the reverse direction. I want to open Excel from SolidWorks.
Set ExSheet = CreateObject("Excel.Sheet")
ExSheet.Application.Visible = True
Set exDoc = ExSheet.ActiveDoc
' Load Excel and expand window
Set exDoc = ExSheet.OpenDoc("folder location\file.xls", 1)
Set exDoc = ExSheet.ActivateDoc("Pulley.SLDPRT")
ExSheet.ActiveDoc.ActiveView.FrameLeft = 0
ExSheet.ActiveDoc.ActiveView.FrameTop = 0
ExSheet.ActiveDoc.ActiveView.FrameState = 1
ExSheet.ActiveDoc.ActiveView.FrameState = 1
I’m getting lost at the point where Excel opens. It opens Excel and a sheet, but stops at the bold text line. The debugger message box opens and displays “Object doesn’t support this method or property”. I believe that I’m using the wrong syntax to keep going in Excel so I can’t even tell if the rest would be correct.
Any suggestions? My API experience is very basic. I’m a cutter and paster from examples and try to get them to work. So anything would help.
Christopher Zona - Senior CAD Designer
Concord, Ontario