Message 1 of 2
help with condition "IF" for macro

Not applicable
08-14-2013
02:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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