fields in a powerpoint document

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a master document that I can populate with entries in
specific fields from either the document properties or an entry form (i.e. a
master document that I can then easily change the client name, date, project
name etc. throughout the document.
Any help gratefully received!
 
This vba would swap any instance of "xname" with the name you input when it
runs. It could easily be extended to swap "xtitle" etc.

Sub merger()
On Error GoTo errhandler
Dim xname As String
xname = InputBox("Name")
Dim osld As Slide
Dim oshp As Shape
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.HasTextFrame And oshp.TextFrame.HasText Then
With oshp.TextFrame
If .TextRange = "xname" Then .TextRange = xname
End With
End If
Next
Next
Exit Sub
errhandler:
MsgBox ("Sorry there's been an error!")
End Sub
--

Did that answer the question / help?
_____________________________
John Wilson
Microsoft Certified Office Specialist
http://www.technologytrish.co.uk/ppttipshome.html
 
With a little more thought the previous code will only work if xname is the
sole content of the text frame!

This may work better
Sub merger()
On Error GoTo errhandler
Dim xname As String
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
xname = InputBox("Name")


Set osld = Application.ActivePresentation.Slides(1)
For Each oshp In osld.Shapes
Set oTxtRng = oshp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:="xname", _
Replacewhat:=xname, WholeWords:=True)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start + oTmpRng.Length, _
oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:="xname", _
Replacewhat:=xname, WholeWords:=True)
Loop
Next oshp

Exit Sub
errhandler:
MsgBox ("Sorry there's been an error!")
End Sub


--

Did that answer the question / help?
_____________________________
John Wilson
Microsoft Certified Office Specialist
http://www.technologytrish.co.uk/ppttipshome.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top