This is driving me crazy. I'm automating the generation of PowerPoint slides from an Access DB containing status reports. Everything works OK when generating a single report (I wish, though, that pasting a rich text field into a PowerPoint text box would
yield better looking results -- the formatting of bulleted text loses hanging indents -- but that's another issue). When I try to create a deck of multiple reports I run into a problem.
The only way to copy rich text to PowerPoint is by selecting all content in the bound text control on the Access form, copying it to the clipboard, then doing ".PasteSpecial ppPasteHTML" into the PowerPoint TextRange of the shape. Simply doing an assignment
of the text value or any other kind of paste results in HTML tags being shown in the PowerPoint shape. Please correct me if I'm wrong and there is a better approach.
Here's the code that decides where the text should come from (the form with the single status report view or the form driving generation of a deck of reports) and how it copies/pastes the text into PowerPoint:
If Singleton Then
Forms![Project Rag NB].SetFocus
Forms![Project Rag NB].RagSummOverall.SetFocus
Forms![Project Rag NB].RagSummOverall.SelLength = Len(Forms![Project Rag NB].RagSummOverall)
DoCmd.RunCommand acCmdCopy ' this always copies text to the clipboard
Else
Forms![Generate Deck].SetFocus
Forms![Generate Deck].RagSummOverall.SetFocus
Forms![Generate Deck].RagSummOverall.SelLength = Len(Forms![Generate Deck].RagSummOverall.Value)
DoCmd.RunCommand acCmdCopy ' this never copies text to the clipboard
End If
'ClipBoard_SetText (Forms![Generate Deck].RagSummOverall.Value)
With ppSlide.Shapes("txtStatusSummary").TextFrame.TextRange
'.Text = rst.Fields("RagSummOverall").Value
.PasteSpecial ppPasteHTML
.ParagraphFormat.Alignment = ppAlignLeft
.ParagraphFormat.SpaceBefore = 0
.ParagraphFormat.SpaceAfter = 0.22
.Font.Color = RGB(0, 44, 119)
.Font.Size = 8
End With
When Access executes the lines after the else I wind up with a pop-up error message:
Run-time error '-2147024809 (80070057)': The specified value is out of range.
The text boxes on both source forms have identical properties save for size and position. Why does Access refuse to copy text from the [Generate Deck] form is a mystery to me. I hope the exercise of creating this request for help will result in an "Aha!"
experience after I click Submit but I have a feeling I'm up a creek without a paddle on this one. I'd love to hear from others who have done non-trivial work on automating PowerPoint and possibly solved the problem of not rendering rich-text correctly after
it's copied from Access.
Thanks!
-Gene