Results 1 to 3 of 3

Thread: PowerPoint VB issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,715
    Location
    The original looked like Excel macro recorder produced code

    This is a little cleaner and includes John's fix


    Option Explicit
    
    
    Sub CreatePrescribingConsiderationsDeck()
        Dim PowerPointPres As Object
       
        ' Create a new PowerPoint presentation
        Set PowerPointPres = Application.Presentations.Add
       
        ' Add a title slide
        With PowerPointPres.Slides.Add(1, ppLayoutTitle)
            .Shapes.Title.TextFrame.TextRange.Text = "Prescribing Considerations in Older People"
       End With
       
        ' Add content slide - Problems with Polypharmacy
        With PowerPointPres.Slides.Add(2, ppLayoutText)
            .Shapes(ppPlaceholderTitle).TextFrame.TextRange.Text = "Problems with Polypharmacy"
            .Shapes.Placeholders(ppPlaceholderBody).TextFrame.TextRange.Text = _
                "Polypharmacy, the use of multiple medications, can pose significant challenges in older people:" & vbCrLf & _
                "- Increased risk of drug interactions" & vbCrLf & _
                "- Higher likelihood of medication non-adherence" & vbCrLf & _
                "- Increased potential for adverse drug reactions"
        End With
        
        ' Add content slide - Cholinergic Burden
        With PowerPointPres.Slides.Add(3, ppLayoutText)
            .Shapes(ppPlaceholderTitle).TextFrame.TextRange.Text = "Cholinergic Burden"
            .Shapes(ppPlaceholderBody).TextFrame.TextRange.Text = _
                "Cholinergic burden refers to the cumulative effect of medications with anticholinergic properties. In older people:" & vbCrLf & _
                "- Anticholinergic medications can contribute to cognitive impairment, falls, and delirium" & vbCrLf & _
                "- Assess the cholinergic burden when prescribing medications" & vbCrLf & _
                "- Consider non-pharmacological alternatives when appropriate"
        End With
        
        ' Add content slide - Pain Management
        With PowerPointPres.Slides.Add(4, ppLayoutText)
            .Shapes(ppPlaceholderTitle).TextFrame.TextRange.Text = "Pain Management"
            .Shapes(ppPlaceholderBody).TextFrame.TextRange.Text = _
                "Pain management in older people requires careful consideration:" & vbCrLf & _
                "- Balance the need for effective pain relief with the risk of adverse effects" & vbCrLf & _
                "- Consider individualized approaches based on pain intensity, comorbidities, and functional status" & vbCrLf & _
                "- Non-pharmacological interventions, such as physical therapy or heat/cold therapy, should be explored"
        End With
           
        ' Save the PowerPoint presentation
    '    PowerPointPres.SaveAs "H:\PrescribingConsiderations.pptx"
    '
    '    ' Close the PowerPoint application
    '    PowerPointApp.Quit
    '
    '    ' Release the PowerPoint objects from memory
    '    Set PowerPointSlide = Nothing
    '    Set PowerPointPres = Nothing
    '    Set PowerPointApp = Nothing
       
        MsgBox "PowerPoint deck created successfully!"
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •