I have a ppt that is being saved as a pdf for use as catalog. I would like to be able to name the text shapes based on a unique product id and then update them based on a connection to an access database. I can name the shapes and update the values with vba using an input box (for testing) but I cannot figure out how to loop through all the shapes and update the shape text based on matching the unique ID criteria. Below is what I am using to test renaming and updating from an input box.
Sub UpdateShape() Dim oShape As Shape
Dim objName
On Error GoTo CheckErrors
If ActiveWindow.Selection.ShapeRange.Count = 0 Then
MsgBox "You need to select a shape first"
Exit Sub
End If
objName = ActiveWindow.Selection.ShapeRange(1).Name
objName = InputBox$("Assign a new name and value to this shape", "Update Shape", objName)
If objName <> "" Then
ActiveWindow.Selection.ShapeRange(1).Name = objName
ActiveWindow.Selection.ShapeRange(1).TextFrame.TextRange.Text = objName
End If
Exit Sub
CheckErrors: MsgBox Err.Description
End Sub
What I have in mind is for the catalog creator to name the shapes based on the images they are putting in the catalog. The pricing will come from the database based on which customer the catalog is being created for. I would like for the vba to loop through the database records and return the sale price based on matching the product ID with the shape name.
I have tried using Set oShape = ActivePresentation.Slides("MySlide").Shapes("MyShape") and oShape.TextFrame.TextRange.Text = "objName"
But I cannot get the text to update and I cannot figure out how to use a variable in place of "MySlide"
The name of the table is tblProduct. The name of the product id field is productid. the name of the sale price field is saleprice.
I appreciate any help I can get.
Thanks