Share via

RunCommand acCmdCopy Problem

Anonymous
2014-07-25T16:29:41+00:00

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

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2014-07-28T18:18:15+00:00

    Solved the mystery!  While the text fields were indeed the same type (Rich Text) the forms they were on were different.  The text field that was successfully copied to the clipboard was on a Split Form (with the data table visible below the form fields).  The text field that was failing was on a regular form.  Switching that to a Split Form enable to copy command to work.

    Moral of the Story: One who lives by the Split Form dies by the Split Form.  Time to look for posts related to Split Form related gotchas.

    Was this answer helpful?

    0 comments No comments