AnsweredAssumed Answered

Invisible solidworks VBA process help

Question asked by Alex Smith on Dec 16, 2014
Latest reply on Dec 18, 2014 by Alex Smith

I have having a problem and not sure how to solve it.  I am making a macro using VBA to open a file invisible and perform a save as to a new name and exit.  The code is below:

 

Option Compare Database

Dim swApp As Object

 

Dim Part As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

 

Private Sub Command0_Click()

 

Set swApp = CreateObject("sldworks.application")

 

Set Part = swApp.OpenDoc6("D:\SWIM_CACHE\3005622.SLDASM", 2, 0, "", longstatus, longwarnings)

swApp.ActivateDoc2 "3005622.SLDASM", False, longstatus

Set Part = swApp.ActiveDoc

Dim myModelView As Object

Set myModelView = Part.ActiveView

longstatus = Part.SaveAs3("D:\SWIM_CACHE\temp.SLDASM", 0, 2)

 

swApp.ExitApp

End Sub

 

The macro works great for the smaller subassemblies which are merely used for testing the code, but the ones I ultimately want to process is much larger in comparison to the ones I have been testing.  When pulling the assembly in a regular session, there are a series of windows that popup during regeneration i.e. saves, errors, etc. before you reach the assembly.  Attached is the error code I get.  Can anyone give me any pointers or possibly modify the code I presented above?  Thanks for the new knowledge in advance!

 

Outcomes