Visual Basic Save - Type Mismatch

Hi,

I have a SolidWorks macro that saves filetypes from a part drawing, ie. with the drawing open, you select the filetypes to save, and the macro opens the model and saves the files.

I am trying to make a DLL using Visual Basic, and have copied across the macro to Visual Basic 2005 Express.

When I run the macro, it creates a 'Type Mismatch' error when it runs the segment of code that saves the filetype.

The segment of code looks like:

If WantParasolid.Checked = True Then 'Save off Parasolid File bRet = swDrawModel.SaveAs4("C:\fred.x_t", _ swSaveAsCurrentVersion, _ swSaveAsOptions_Silent, _ nErrors, _ nWarnings) End If

Earlier the declarations were:

Dim iSwApp As SldWorks.SldWorks Dim iSwModel As SldWorks.ModelDoc2 Dim swDrawModel As Object

Dim bRet As Boolean Dim swSaveAsCurrentVersion As Long Dim swSaveAsOptions_Silent As Long Dim nErrors As Long Dim nWarnings As Long

swDrawModel = iSwApp.OpenDoc6(sFullFilePath, DocType, 0, "", nErrors, nWarnings) swDrawModel = iSwApp.ActivateDoc(ModelName)

Can anyone help?

Thanks

Reply to
ahoneyfield
Loading thread data ...

Got the answer from another source. Trick is to declare swDrawModel at the start of the file as:

Dim swDrawModel As SldWorks.ModelDoc2

Strangely, this was not necessary as a macro - it was only needed once we switched to VB2005 Express to create a DLL.

Reply to
ahoneyfield

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.