I have a PDF file that I have created in Bluebeam. It has shapes, images and text boxes throughout it.
Using VBA in Excel, I want to replace all occurrences of a string. I've tried many different peoples suggestions from other pages which successfully replace the string however, when i open the file in bluebeam, many of the shapes will have shifted or disappeared. The files encoding is ANSI.
Any wisdom to replace occurrences without messing up the other contents of the file?
Here is the code ive been playing with (from here):
Sub Test()
Dim objFSO
Const ForReading = 1
Const ForWriting = 2
Dim objTS 'define a TextStream object
Dim strContents As String
Dim fileSpec As String
fileSpec = ThisWorkbook.path & "\Template.pdf"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTS = objFSO.OpenTextFile(fileSpec, ForReading, False)
strContents = objTS.ReadAll
strContents = replace(strContents, "PLACEHOLDER", "TOPDOG")
objTS.Close
Set objTS = objFSO.OpenTextFile(fileSpec, ForWriting)
objTS.Write strContents
objTS.Close
End Sub