0
votes

Good Day! I have a problem, i know how to copy a picture or a shape from MS Word to PPT and making a presentation, however couldn't get my head around how to do the same with text.

The original idea was to copy via Paragraphs. It has titles, not one but many, and main text for each title. I started by creating a presentation and adding a slide. I would like to loop through all text in Word Document opened and copy it to PP title to title and main text to main textbox of PP presentation. Would appreciate any help

 Sub WordToPPt()
    Dim PPTApplication As PowerPoint.Application
    Dim activeSlide As PowerPoint.Slide
        
    On Error Resume Next
    Set PPTApplication = GetObject(, "PowerPoint.Application")
    On Error GoTo 0
 
    If PPTApplication Is Nothing Then
        Set newPowerPoint = New PowerPoint.Application
    End If

    If PPTApplication.Presentations.Count = 0 Then
        PPTApplication.Presentations.Add
    End If
 
    PPTApplication.Visible = True
End Sub

Samples https://imgur.com/ElvJoC1 another one https://imgur.com/Lc9PQql

1
Could you please tell us how your word document is structured. For example paragraph 1 is the Title 1, paragraph 2 is Main Text 1, paragraph 3 is Title 2, paragraph 4 is Main Text 2 and so on. - Super Symmetry
Actually it is precisely as you described, paragraph 1 is the title, paragraph 2 is the main text. Although paragraph 3 is also main text, paragraph 4 is new Title, and it always varies. There is no pattern for Titles to track. Like every 3rd or 4th paragraph is the Title. Always different - Tahir Ruzbaev
How do you identify which paragraph is a title and which is main text? Have you used heading styles for the titles? - Timothy Rylatt
In this case it is going to be very difficult to tell which is which. There must be a pattern in order to distinguish between title and main text. A pattern could be as simple as every odd/even paragraph. It could aslo be a simple check like the number of characters. Is it for example safe to assume that the number of characters in a title is always less than the main text? Can you for example add a leading title identifier to the text manually? It could be something like "*T*" and you can check if the paragraph starts with this pattern means it's a title. Can you upload a sample document? - Super Symmetry
I have uploaded few samples. On the first sample the title is the beginning of the new Section like Construction section and articles about it, then Environment section articles about it. So the first sample, it has the title, translated: Question-Answer - has to be the title and then goes the rest as main text with hyperlink then article - but all of that is the main text. @ Timothy Rylatt We can say that only the title has uppercase symbols (capital letters) - Tahir Ruzbaev

1 Answers

0
votes

I have managed to identify paragraphs by Styles as they are all different

If ActiveDocument.Paragraphs(J).Style = ("STYLE_NAME") Then

however faced another problem when I want to make a reverse order of slides when insert the cut slide

Dim SlidesNumber As Long Dim x As Long

   SlidesNumber = mypresentation.Slides.Count

        For x = 1 To SlidesNumber - 1

          ' Reorder the slides.
          mypresentation.Slides(SlidesNumber).Cut
          mypresentation.Slides.Paste SlidesNumber 'here is where the problem pops out
       Next x
    End If

keep on getting Slides.Paste: Invalid request. Clipboard is empty or contains data which may not be pasted here

Can someone explain why it worked first few times and stopped working after that. And what would be the solution?