AnsweredAssumed Answered

Help with Macro for Adding part of File name to Property

Question asked by Daniel Finn on Apr 18, 2018
Latest reply on Apr 19, 2018 by Christian Chu

Hi,

 

I would appreciate anyone that can help with this.

 

To briefly explain what i am trying to do, we name our files as following eg: TE1234 Description

 

I want to pull out the first 6 letters which i have succeeded in doing using the following code:

 

Dim swApp As SldWorks.SldWorks

Dim swModel As ModelDoc2

 

Sub main()

 

     Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

 

     swModel.DeleteCustomInfo ("JobNo")

    swModel.AddCustomInfo2 "JobNo", swCustomInfoText, Left(swModel.GetTitle, 6)

 

End Sub

 

The issue i have is that there are occasions when a part may be labelled what it is eg: M6x12mm Screw

With this macro it pulls through the first 6 digits.

 

Is there a way to specify for instance, if the filename does not start with 2 letters and followed by 4 digits then ignore and leave blank

 

Any help would be appreciated with this

Outcomes