Hey!
I'm writing a macro that reads a citation from a text file. After it had been read I want to be able to add the citation string right after the text where the person was writing (and the flashing cursor is). The problem is that I need to keep track of the different citations that I added, because I want to be able to loop through all the citations that I added this way, and add them to a new slide with all the added citations.
The way I'm doing it now is by adding a textbox with the name "citationBox" to the current slide, and if the textbox already exists, I add the new strings to it aswell. This way I can loop through all the slides and check if it contains a shape called "citationBox" and copy its value to a new string that will contain all added citations.
The problem is that with textboxes I haven't found a way to add it inline on the position where the user was typing. I can add it inline just as a textrange, but then I'm not able to give the citation a name or id and thus can't find it anymore to add it to the slide that contains all citations.
Any ideas on how to solve my problem?
This is the code I use to make a new slide with the citations:
Dim pptSlide As Slide Dim pptLayout As CustomLayout
Dim sld As Slide
Dim shp As Shape
Dim citationString As String
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If (shp.name = "citationBox") Then
citationString = citationString & vbNewLine & shp.TextFrame.TextRange.text
End If
Next shp
Next sld
If ActivePresentation.Slides.Count > 1 Then
Set pptLayout = ActivePresentation.Slides(2).CustomLayout
Else
Set pptLayout = ActivePresentation.Slides(1).CustomLayout
End If
Set pptSlide = ActivePresentation.Slides.AddSlide((ActivePresentation.Slides.Count + 1), pptLayout)
pptSlide.Shapes.Title.TextFrame.TextRange.text = "References"
pptSlide.Shapes(2).TextFrame.TextRange = citationString