Sidtha
Aerospace
- Nov 25, 2012
- 32
Hello,
I need macro to get all items linked to leader.
Case 1-Sinlge leader one time all items linked to the leader.
case 2 - if multiple leaders connected to same items should give quantity based on the number of leaders.
For ref:
Please help me to get the same.
I have written the code below not getting the result as expected.
Sub General_Check()
Dim wb As Workbook, ws As Worksheet
Set wb = ThisWorkbook
Set ws = wb.Sheets("TestBOM")
Dim CATIA As Object
Dim myselection As Selection
Dim textlist() As String
Dim showstate As CatVisPropertyShow
LR = ws.Cells(Rows.Count, 1).End(xlUp).Row
ws.Range("A2:I100000").ClearContents
Set CATIA = GetObject(, "CATIA.Application")
Dim drawingDocument1 As Document
Set drawingDocument1 = CATIA.ActiveDocument
Set oDrwView = drawingDocument1.Sheets.ActiveSheet.Views
Dim pattern As String
pattern = "\b(?:\d{1,3}-\d{1,2}|((?<!-)1\d{3}))\b"
Dim Selection1 As Selection
Set myselection = drawingDocument1.Selection
'myselection.Search "CATDrwSearch.DrwBalloon,all"
myselection.Search "Name=*Text*,all"
j = 2
For i = 1 To oDrwView.Count
'For i = 1 To myselection.Count
Set selectedBalloon = myselection.Item(i).Value
Set myleaders = selectedBalloon.Leaders
On Error Resume Next
For numtxt = 1 To oDrwView.Item(i).Texts.Count
Set CurrentText = oDrwView.Item(i).Texts.Item(numtxt)
If CurrentText.FrameName = "Circle" Then
ws.Cells(j, 1).Value = oDrwView.Name
ws.Cells(j, 2).Value = oDrwView.Item(i).Name
'ws.Cells(j, 3).Value = CurrentText.text
ws.Cells(j, 3).Value = selectedBalloon.text
ws.Cells(j, 4).Value = CurrentText.x
ws.Cells(j, 5).Value = CurrentText.y
ws.Cells(j, 6).Value = CurrentText.FrameName
ws.Cells(j, 7).Value = CurrentText.TextProperties.FontSize
ws.Cells(j, 8).Value = CurrentText.TextProperties.FontName
ws.Cells(j, 9).Value = CurrentText.Name
j = j + 1
End If
Next numtxt
Next i
On Error GoTo 0
End Sub
BR
Siddu
I need macro to get all items linked to leader.
Case 1-Sinlge leader one time all items linked to the leader.
case 2 - if multiple leaders connected to same items should give quantity based on the number of leaders.
For ref:
Please help me to get the same.
I have written the code below not getting the result as expected.
Sub General_Check()
Dim wb As Workbook, ws As Worksheet
Set wb = ThisWorkbook
Set ws = wb.Sheets("TestBOM")
Dim CATIA As Object
Dim myselection As Selection
Dim textlist() As String
Dim showstate As CatVisPropertyShow
LR = ws.Cells(Rows.Count, 1).End(xlUp).Row
ws.Range("A2:I100000").ClearContents
Set CATIA = GetObject(, "CATIA.Application")
Dim drawingDocument1 As Document
Set drawingDocument1 = CATIA.ActiveDocument
Set oDrwView = drawingDocument1.Sheets.ActiveSheet.Views
Dim pattern As String
pattern = "\b(?:\d{1,3}-\d{1,2}|((?<!-)1\d{3}))\b"
Dim Selection1 As Selection
Set myselection = drawingDocument1.Selection
'myselection.Search "CATDrwSearch.DrwBalloon,all"
myselection.Search "Name=*Text*,all"
j = 2
For i = 1 To oDrwView.Count
'For i = 1 To myselection.Count
Set selectedBalloon = myselection.Item(i).Value
Set myleaders = selectedBalloon.Leaders
On Error Resume Next
For numtxt = 1 To oDrwView.Item(i).Texts.Count
Set CurrentText = oDrwView.Item(i).Texts.Item(numtxt)
If CurrentText.FrameName = "Circle" Then
ws.Cells(j, 1).Value = oDrwView.Name
ws.Cells(j, 2).Value = oDrwView.Item(i).Name
'ws.Cells(j, 3).Value = CurrentText.text
ws.Cells(j, 3).Value = selectedBalloon.text
ws.Cells(j, 4).Value = CurrentText.x
ws.Cells(j, 5).Value = CurrentText.y
ws.Cells(j, 6).Value = CurrentText.FrameName
ws.Cells(j, 7).Value = CurrentText.TextProperties.FontSize
ws.Cells(j, 8).Value = CurrentText.TextProperties.FontName
ws.Cells(j, 9).Value = CurrentText.Name
j = j + 1
End If
Next numtxt
Next i
On Error GoTo 0
End Sub
BR
Siddu