Consulting

Results 1 to 3 of 3

Thread: ppt: switch between two open ppt presentations (documents are variable names)

  1. #1

    ppt: switch between two open ppt presentations (documents are variable names)

    I have two sheets ("000-macros for report.pptm" and "slides 07-25-23.pptx")

    my goal is to

    1. start on slides sheet
      1. save slides sheet name as startfilename (variable)

    2. switch to macro sheet
      1. save macro sheet name as macrodocument (variable)

    3. switch back to codes sheet
      1. this codes sheet name can be different name each time. that is why I saved it as startfilename


    I tried to just include relevant code



    Dim StartPres As Presentation
    Dim macrodocument As String
    Dim StartFileName As String
    Set StartPres = ActivePresentation
    StartFileName = ActivePresentation.Name      'startfilename is now set to "slides 07-25-23.pptx"
    Presentations("000-macros for report").Windows(1).Activate        
    macrodocument = sld.Shapes("Macro Doc Value").TextFrame.TextRange.Text    ' macrodocument is not set to "000-macros for report.pptm"
    Presentations(StartFileName).Windows(1).Activate    'this is where the issue is

  2. #2
    Hello, I think instead of relying on the ActivePresentation object, you can directly use the filename of the "slides 07-25-23.pptx" presentation. Here's an updated version of your code:


    Dim StartPres As Presentation
    Dim macrodocument As String
    Dim StartFileName As String
    Set StartPres = ActivePresentationStartFileName = "slides 07-25-23.pptx" ' Assign the filename directly
    Presentations("000-macros for report.pptm").Windows(1).Activatemacrodocument = StartPres.Slides(1).Shapes _
    ("Macro Doc Value").TextFrame.TextRange.Text
    Presentations(StartFileName).Windows(1).Activate
    In this code, the StartFileName variable is assigned the filename directly as a string. You can replace "slides 07-25-23.pptx" with the actual filename if it varies each time.

    Note that the line macrodocument = StartPres.Slides(1).Shapes("Macro Doc Value").TextFrame.TextRange.Text assumes that the "Macro Doc Value" shape is located on the first slide of the "slides 07-25-23.pptx" presentation. If the shape is on a different slide, you'll need to adjust the slide index accordingly.

  3. #3
    VBAX Newbie
    Joined
    May 2023
    Posts
    2
    Location
    The provided code snippet assumes that the filename is constant and hardcoded as "slides 07-25-23.pptx". If the filename varies each time or needs to be dynamic, you can replace it with a variable that holds the actual filename. Here's an example of how you can modify the code to use a variable for the filename:
    Dim StartFileName As String
    StartFileName = "your_actual_filename.pptx"
    ' Rest of the code...
    Set StartPres = StartApp.Presentations.Open(StartFileName)
    ' Rest of the code...
    geometry dash scratch

Posting Permissions

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