help with condition "IF" for macro

help with condition "IF" for macro

Anonymous
Not applicable
310 Views
1 Reply
Message 1 of 2

help with condition "IF" for macro

Anonymous
Not applicable

Hi,

I trying create simply macro for my work. It is mass rename for *.ipt files and their iProperty.

 

And i need create condition "IF" for this (example 2 files):

 

4-1903-01 Pachole.ipt  -> iProperties-Summary-Subject = nothing

4-1903-02-01 Dachole 2.ipt  -> iProperties-Summary-Subject = "4-1903-02" (first 9 symbols)

 

How to do it? Maybe find first symbol "space"

 

Thank you for reply and here is macro:

 

Public Sub UpdateDocs()
'JDK 2013
' Include REF to Microsoft Scripting Runtime
    Dim oApp As Application
    Set oApp = ThisApplication
    Dim oDoc As PartDocument
    Dim oPropSet As PropertySet
    Dim FSO As New Scripting.FileSystemObject
    Dim oFld As Scripting.Folder
    Dim oFile As Scripting.File
    Dim Path As String
    Dim sTitle As String
        
    ' ==========================================================================
    ' ==PATH DEFINUJE CESTU SLOŽKY VE KTERÉ BUDE MĚNIT VLASNOSTI *.IPT SOUBORŮ==
    ' ==========================================================================

        Path = "G:\prace\4-1901 PACHOLE\4-1902-01 PACHOLE"
        If FSO.FolderExists(Path) Then
            Set oFld = FSO.GetFolder(Path)
        Else
            MsgBox ("Folder Does Not Exist")
            Exit Sub
        End If
    oApp.SilentOperation = True
        For Each oFile In oFld.Files
            getExt = Split(oFile.Name, ".")
            sExt = getExt(1)
            sName = getExt(0)
            sKey = Left(sName, 12)
            sTitle = "DATABAZE"
                If InStr(sExt, "ipt") Then
                    Set oDoc = oApp.Documents.Open(oFile, False)
                    If oDoc.DocumentType = kPartDocumentObject Then
                        sName = sKey
                        Dim oSummaryPropSet As PropertySet
                        Set oSummaryPropSet = oDoc.PropertySets.Item( _
                        "Summary Information")
                        oSummaryPropSet.Item("Title").Value = sTitle
                        Dim oDesignPropSet As PropertySet
                        Set oDesignPropSet = oDoc.PropertySets.Item( _
                        "Design Tracking Properties")
                        oDesignPropSet.Item("Part number").Value = sName
                        With oDoc
                            .Update
                            .Save
                            .Close
                        End With
                    End If
                End If
        Next
    oApp.SilentOperation = False
    Set oFile = Nothing
    Set oFld = Nothing
    Set FSO = Nothing
End Sub


 

 

 

 

 

0 Likes
311 Views
1 Reply
Reply (1)
Message 2 of 2

ekinsb
Alumni
Alumni

I'm sure what you want to do can be done but you didn't provide enough information for me to be able to help.  What is the difference between the two strings that you're looking for to determine if you should use it or not.  The version number of the first part has 3 parts and the second one has 4 parts.  Is that the trigger?


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes