Excel VBA - Realça a forma do powerpoint e identifica a linha de texto que não está no intervalo do Excel

1

Estou escrevendo uma macro para identificar se as linhas de texto em uma forma do PowerPoint não estão presentes em um intervalo do Excel.

A ideia no último loop é que, se a linha de texto na forma não for encontrada no intervalo do Excel, ela será gravada. Ele não está funcionando, pois o código está retornando todas as linhas na forma, o que significa que nenhuma foi encontrada e, se eu adicionar uma condição Not , ela não retornará nenhuma linha, mesmo aquelas que não estejam no intervalo do Excel. / p>

Alguma idéia?

Aqui está o meu código:

Sub Updt_OrgChart_Test1()

Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide

Set PPApp = CreateObject("Powerpoint.Application")

PPApp.Visible = True


Set PPPres = PPApp.Presentations("presentation 2016.pptx")
Set PPSlide = PPPres.Slides(6)

Dim wb As Workbook
Dim teste_ws As Worksheet
Dim SDA_ws As Worksheet

Set wb = ThisWorkbook
Set teste_ws = wb.Sheets("Teste")
Set SDA_ws = wb.Sheets("FZ SW KRK SDA")

Dim shp As PowerPoint.Shape

Dim L5AndTeam As String
L5AndTeam = SDA_ws.Range("C3")
Dim Employee_Rng As Range
Set Employee_Rng = SDA_ws.Range(Range("B8"), Range("B8").End(xlDown))

For Each shp In PPSlide.Shapes
     On Error Resume Next
     If shp.TextFrame.HasText Then
       If shp.TextFrame.TextRange.Lines.Count > 2 Then
         If Left(shp.Name, 3) = "Rec" Then
            Dim prg As PowerPoint.TextRange
            For Each prg In shp.TextFrame.TextRange.Paragraphs
                Dim nm As String
                nm = prg
                If Employee_Rng.Find(nm.Value) Is Nothing Then
                   MsgBox nm  <---- this is just a test, will add more code here
                End If
            Next prg
           End If
        End If
     End If
Next shp

End Sub
    
por sptfire101 20.09.2016 / 12:49

1 resposta

0

Talvez seja melhor fazer uma iteração na coleção Parágrafos ou Linhas do TextRange da forma. Exemplo simples que pressupõe uma caixa de texto selecionada:

Sub Thing()

Dim oSh As Shape
Dim x As Long

Set oSh = ActiveWindow.Selection.ShapeRange(1)

If oSh.HasTextFrame Then
    With oSh.TextFrame.TextRange
        For x = 1 To .Paragraphs.Count
            Debug.Print .Paragraphs(x).Text
        Next
        For x = 1 To .Lines.Count
            Debug.Print .Lines(x).Text
        Next
    End With
End If

End Sub

Note que você pode passar por parágrafos ou linhas (parágrafo = você digitou um ENTER no final; linha = você digitou um quebra de linha ou a linha foi quebrada por quebra de linha)

    
por 20.09.2016 / 17:09