Hallo!
Ich versuche, eine rekursive Makro benenne ich alle ein Produkt partNumber seinem Dateiname zu machen, sondern die Beseitigung der letzten 4 Zeichen, aber mach mich nicht falsch auf dieser Linie
strNewName = Replace(strOldName, ".CATProduct", "")
strNewName2 = Right(strNewName.Name, 15)
..... Können Sie mir helfen?
Das ist code komplet:
'Option Explicit
Sub CATMain()
On Error GoTo 0
Dim oRoot As Document
Set oRoot = CATIA.ActiveDocument
Dim oProduct As Product
Set oProduct = oRoot.Product
Dim oProducts As Products
Set oProducts = oProduct.Products
Dim strOldName As String
Dim strNewName As String
strOldName = oRoot.Name
strNewName = Replace(strOldName, ".CATProduct", "")
oProduct.PartNumber = strNewName
RecursiveThroughTree_fn2pn oProducts
End Sub
Sub RecursiveThroughTree_fn2pn(oProducts As Products)
Dim oProduct As Product
Dim oRefProduct As Product
Dim oRefDocument As Document
For Each oProduct In oProducts
Set oRefProduct = oProduct.ReferenceProduct
Set oRefDocument = oRefProduct.Parent
Dim strOldName As String
Dim strNewName As String
Dim strNewName2 As String
Dim strOldPath As String
Dim strNewFullName As String
If TypeName(oRefDocument) = "ProductDocument" Then
Dim oProdDoc As ProductDocument
Set oProdDoc = oRefDocument
strOldName = oProdDoc.Name
strNewName = Replace(strOldName, ".CATProduct", "")
strNewName2 = Right(strNewName.Name, 15)
oProdDoc.Product.PartNumber = strNewName
If oProduct.Products.Count > 0 Then
RecursiveThroughTree_fn2pn oProduct.ReferenceProduct.Products
End If
ElseIf TypeName(oRefDocument) = "PartDocument" Then
Dim oPartDoc As PartDocument
Set oPartDoc = oRefDocument
strOldName = oPartDoc.Name
strNewName = Replace(strOldName, ".CATPart", "")
strNewName2 = Right(strNewName.Name, 15)
oPartDoc.Product.PartNumber = strNewName
End If
Next
End Sub
Und das ist die alte Partnumber ich habe :
DJ119700-50500A01.CATProduct
Und das ist das anwort ich brauche :
DJ119700-50500.CATProduct
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP