Question

I have created a function that allows a user to import one or more text files into a field in PowerPoint. This works really well. The user clicks in the field, clicks the button on the custom menu, selects the files from a list and in they go. The problem I have is that I have to put two returns between each imported text, which means there are two left on the end.

This is the usual result to delete a paragraph I have found:

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=27, Length:=1).Select
ActiveWindow.Selection.TextRange.Text = ""

This suggests I would have to calculate the last position int he selected field to be able to delete it. Could anyone give me an idea of how I would go about this?

Was it helpful?

Solution

This solution is a bit easier (not tested):

dim tmpTXT as string
    tmpTXT = ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Text
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Text = Left(tmpTXT, len(tmpTXT) -1)

You could do something similar earlier, before you write text to your shape which would be better.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top