vov44k

Untitled

Aug 28th, 2024 (edited)
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.37 KB | None | 0 0
  1. Sub RemoveGluePointsAndConnections()
  2.     Dim pg As Page
  3.     Dim shp As Shape
  4.     Dim secIndex As Integer
  5.     Dim row As Integer
  6.     Dim cellX As Cell
  7.     Dim cellY As Cell
  8.     Dim i As Integer
  9.  
  10.     ' Перебираем все страницы в документе
  11.    For Each pg In ActiveDocument.Pages
  12.        ' Перебираем все фигуры на странице
  13.         For Each shp In pg.Shapes
  14.             ' Удаление всех Connection Points (Точек соединения)
  15.            If shp.SectionExists(visSectionConnectionPts, False) Then
  16.                For i = shp.RowCount(visSectionConnectionPts) - 1 To 0 Step -1
  17.                    shp.DeleteRow visSectionConnectionPts, i
  18.                Next i
  19.            End If
  20.  
  21.            ' Проверяем стандартные секции, такие как Geometry, которые могут содержать PAR(PNT(...))
  22.             For secIndex = visSectionObject To visSectionFirstComponent - 1
  23.                 If shp.SectionExists(secIndex, False) Then
  24.                     ' Перебираем строки в секции
  25.                    For row = 0 To shp.RowCount(secIndex) - 1
  26.                        ' Обрабатываем ячейки X и Y
  27.                         On Error Resume Next ' Пропускаем возможные ошибки
  28.                        Set cellX = shp.CellsSRC(secIndex, row, visX)
  29.                        Set cellY = shp.CellsSRC(secIndex, row, visY)
  30.                        
  31.                        ' Если формула содержит PAR(PNT(...)), заменяем её на абсолютное значение
  32.                         If InStr(cellX.FormulaU, "PAR(PNT") > 0 Then
  33.                             cellX.ResultIU = cellX.ResultIU
  34.                         End If
  35.                         If InStr(cellY.FormulaU, "PAR(PNT") > 0 Then
  36.                             cellY.ResultIU = cellY.ResultIU
  37.                         End If
  38.                         On Error GoTo 0 ' Возвращаем нормальную обработку ошибок
  39.                    Next row
  40.                End If
  41.            Next secIndex
  42.        Next shp
  43.    Next pg
  44.  
  45.    MsgBox "Все точки соединения удалены, формулы с PAR(PNT(...)) заменены на абсолютные значения."
  46. End Sub
  47.  
Advertisement
Add Comment
Please, Sign In to add comment