AnsweredAssumed Answered

How to save with overwrite within a macro. Must overwrite the model in result that the thumbnail is correct

Question asked by Jean Stassen on Nov 10, 2015
Latest reply on Nov 12, 2015 by Jean Stassen

Please comment on macro. Ive used a macro from internet and I am a BEGINNER in API !

I've headlighted the part of the macro where the question refers to.

I want to have SW overwrite the savename in result that the thumbnail in explorer is right.

I can't find the right API to do so.

 

Thank yout in advance for your help

 

 

 

Option Explicit

Dim swApp        As SldWorks.SldWorks 
Dim swModel      As SldWorks.ModelDoc2
Dim swDrawing    As SldWorks.DrawingDoc

Dim strFileName  As String
Dim saveFilename As String
Dim strPath      As String
Dim boolStatus   As Boolean
Dim longStatus   As Long
Dim longErrors   As Long
Dim longWarnings As Long
 
Sub main()
   
    Set swApp = Application.SldWorks
       
    strPath = "F:\Mijn documenten\40 Try-outs SW\2015\Macro's\Concept\Test Directory voor macro\2011_206_06 capafgifte"
    strPath = strPath + "\"

Debug.Print strPath
   
    strFileName = Dir(strPath & "*.sldprt") ' Change .sldprt to any other extension you need. Think about OpneDoc or LoadFile
   
    Do Until strFileName = ""

Debug.Print strFileName

    'deze regel is voor NON Solidworks files als model in te lezen in solidworks, voor SW files opendoc6 gebruiken ' --> boolstatus = swApp.LoadFile2(strPath + strFileName, "")
  
    Set swModel = swApp.OpenDoc6(strPath + strFileName, swDocPART, swOpenDocOptions_Silent, "", longErrors, longWarnings)
            
        swModel.ShowNamedView2 "*Isometric", 7 'isometrisch plaatsen in file
        swModel.ViewZoomtofit2
            
    'longStatus = swModel.SaveAs3(strPath + swModel.GetTitle, 0, 2)
    saveFilename = Left(swApp.ActiveDoc.GetPathName, Len(swApp.ActiveDoc.GetPathName) - 6)    'De bewaarnaam verkrijgen om te kunnen overwriten
    'swModel.SaveAs2 saveFilename, 0, True, False
   
   
   swApp.CloseDoc swModel.GetTitle
  
  
Set swModel = Nothing

 

strFileName = Dir
  
Debug.Print strFileName
  
Loop

End Sub

Outcomes