charbroil
Aerospace
- Jul 23, 2004
- 29
I need to pose a simple question about API programming with VB6.
I want to write a larger macro, but am so rusty with VB programming that I am inching through, recording only snippets at a time and analyzing the code. When I record a macro and try to play it back, I get errors that I don’t expect.
For instance, I have a blank drawing and I record a macro that creates a new sheet. Then I delete the new sheet and play the macro. I get Run Time Error 450 (Wrong number of arguments or invalid property assignment) on the line I bolded:
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("###", "SHEET", 0.02101312365445, 0.1932208491231, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
Part.NewSheet3 "Sheet2", 12, 12, 1, 1, False, "npi_title-block_sizeA.slddrt", 0.2794, 0.2159, "Default", True
End Sub
What exactly is wrong with that and why wouldn’t it be correctly structured straight from the recorder?
I’m sorry if this is soooo basic. I have put in for an API training class, but it may not happen for months.
System: Dell Precision 650—Intel Xeo @ 2.66 GHz with 1/2G RAM
OS: Windows 2000 SP3
Graphics: NVidia Quadro FX 500 128Mb (OpenGL set to Solidworks)
Version: Solidworks 2005, SP0
I want to write a larger macro, but am so rusty with VB programming that I am inching through, recording only snippets at a time and analyzing the code. When I record a macro and try to play it back, I get errors that I don’t expect.
For instance, I have a blank drawing and I record a macro that creates a new sheet. Then I delete the new sheet and play the macro. I get Run Time Error 450 (Wrong number of arguments or invalid property assignment) on the line I bolded:
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("###", "SHEET", 0.02101312365445, 0.1932208491231, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
Part.NewSheet3 "Sheet2", 12, 12, 1, 1, False, "npi_title-block_sizeA.slddrt", 0.2794, 0.2159, "Default", True
End Sub
What exactly is wrong with that and why wouldn’t it be correctly structured straight from the recorder?
I’m sorry if this is soooo basic. I have put in for an API training class, but it may not happen for months.
System: Dell Precision 650—Intel Xeo @ 2.66 GHz with 1/2G RAM
OS: Windows 2000 SP3
Graphics: NVidia Quadro FX 500 128Mb (OpenGL set to Solidworks)
Version: Solidworks 2005, SP0