Open Existing PowerPoint via VBA

0 votes

In order to open an existing pptx file and add a new slide to the deck using VBA, I'm referring to an earlier post. The below link is to the post, but, when I try to execute the sub I obtain a "Object Needed" run-time problem after selecting the pptx. I've also provided the code that I tried executing, based on the relevant thread. Any idea how to resolve this error?

Reference Link

Sub Test()
With Application.FileDialog(msoFileDialogFilePicker)
       .AllowMultiSelect = False  'only allows the user to select one file
        ' Set the title of the dialog box.
      .Title = "Select the File."  'Put any text to help the user choose the correct file
        'clear filters then add pptx filter
      .Filters.Add "PowerPoint files", "*.pptx"   ' This can be any file extension to filter the choices
        ' Show the dialog box. If the .Show method returns True, the
        ' user picked at least one file. If the .Show method returns
        ' False, the user clicked Cancel.
      If .Show = True Then
        fxname = .SelectedItems(1)
      End If
   End With
 Set opres = Presentations.Open(fxname, False, False, True) 'opres is the variable for the choosen file
 opres.Windows(1).Activate  'Activates that presentation.
End Sub

When debugging, the Set opres = Presentations.Open(fxname, False, False, True) is what's highlighted as an error.

Mar 24, 2023 in Others by narikkadan
• 63,720 points

1 answer to this question.

0 votes

You do not have the proper reference to open PowerPoint Presentations, open with createobject, look at Open a PowerPoint presentation from Excel with VBA and then set that presentation to a variable

answered Mar 24, 2023 by Kithuzzz
• 38,010 points

Related Questions In Others

0 votes
1 answer

Excel VBA if file closed, then open and paste, else just paste data

Slightly re-worked to add full workbook/sheet qualifiers ...READ MORE

answered Sep 21, 2022 in Others by narikkadan
• 63,720 points
0 votes
1 answer

Hosting Microsoft Edge via WebView2Loader.dll with Excel VBA

Here's an API to communicate with Chromium ...READ MORE

answered Sep 29, 2022 in Others by narikkadan
• 63,720 points
0 votes
1 answer

Open SAP from Excel VBA

It just means that there is no ...READ MORE

answered Sep 30, 2022 in Others by narikkadan
• 63,720 points
0 votes
1 answer

How to modify Powerpoint Chart ChartData by Excel VBA

Example: Code: Set pptApp = GetObject(, "PowerPoint.Application") Set pptPres = ...READ MORE

answered Oct 16, 2022 in Others by narikkadan
• 63,720 points
0 votes
1 answer

Retrieve Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,670 points
0 votes
1 answer

VBA Check to see if file is open before reopening a second file

You could replace the line: Set pre = ...READ MORE

answered Apr 4, 2023 in Others by Kithuzzz
• 38,010 points
0 votes
1 answer

VBA to protect and unprotect in given range in sheet

It needs a minor tweak to become ...READ MORE

answered Nov 24, 2022 in Others by Kithuzzz
• 38,010 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP