Excel VBA to save Powerpoint file

sophie619

New Member
Joined
Aug 23, 2013
Messages
23
Hi all,

I have data in an Excel file that needs to be displayed as a table in PowerPoint. I'm still working on the code for that, but in the meantime, I was trying to write the code to SAVE that powerpoint file once it is created.

Below is the code I'm using, but I'm mostly frustrated by the fact that I don't understand what the Intellisense is trying to get me to do. The line here
Code:
[FONT=arial]ppPres.SaveAs(Filename=sFname,[/FONT]<wbr style="font-family: arial, sans-serif; font-size: 12.8000001907349px;">[FONT=arial]PpSaveAsFileType=[/FONT]<wbr style="font-family: arial, sans-serif; font-size: 12.8000001907349px;">[FONT=arial]ppSaveAsPresentation,[/FONT]<wbr style="font-family: arial, sans-serif; font-size: 12.8000001907349px;">[FONT=arial]msoTristate=msoTriStateMixed)[/FONT]
which is toward the bottom of the code, is where I'm having trouble. The IntelliSense says

SaveAs(FileName As String, [FileFormat as PpSaveAsFileType=ppSaveAsDefault],[EmbedTrueTypeFonts as MsoTriState = msoTriStateMixed]

Can anyone help me understand what it is I'm doing wrong? I've tried this a variety of ways, and I keep getting a compile error. The only way it works is it I just use the FileName parameter, but then it shows up as saving the powerpoint as an excel file, which then doesn't open b/c it's not a supported format (obviously).

Thanks in Advance!



Code:
[COLOR=#000000][FONT=Courier New]Sub CreateDisplaySlide()[/FONT][/COLOR][FONT=arial]Dim ppApp As PowerPoint.Application[/FONT]
[FONT=arial]Dim ppPres As PowerPoint.Presentation[/FONT]
[FONT=arial]Dim ppSlide As PowerPoint.Slide[/FONT]
[FONT=arial]Dim ppTable As PowerPoint.Shape[/FONT]
[FONT=arial]Dim fd As FileDialog[/FONT]
[FONT=arial]Dim sFname As String[/FONT]
[FONT=arial]
Set ppApp = CreateObject("Powerpoint.[/FONT]<wbr style="font-family: arial, sans-serif; font-size: 12.8000001907349px;">[FONT=arial]Application")[/FONT]
[FONT=arial]ppApp.Visible = True 'allows user to see it on the taskbar[/FONT]
[FONT=arial]ppApp.Activate 'Maximizes PowerPoint window[/FONT]

[FONT=arial]Set ppPres = ppApp.Presentations.Add 'stores reference to it as a variable[/FONT]
[FONT=arial]Set ppSlide = ppPres.Slides.Add(1, ppLayoutBlank)[/FONT]
[FONT=arial]ppSlide.Select[/FONT]

[FONT=arial]'insert code to fill in the table [/FONT][FONT=arial]'add KEY (LEGEND) to slide [/FONT][FONT=arial]'if statements about length/width [/FONT][FONT=arial]'center horizontally [/FONT][FONT=arial]'center vertically[/FONT]
[FONT=arial]
'SaveAs code
[/FONT][FONT=arial]Set fd = Application.FileDialog([/FONT]<wbr style="font-family: arial, sans-serif; font-size: 12.8000001907349px;">[FONT=arial]msoFileDialogSaveAs)[/FONT]
[FONT=arial]With fd[/FONT]
[FONT=arial]    .InitialFileName = Environ("userprofile") & "\Desktop\"[/FONT]
[FONT=arial]    If fd.Show = True Then[/FONT]
[FONT=arial]        sMyFile = .SelectedItems(1)[/FONT]
[FONT=arial]        ppPres.SaveAs(Filename=sFname,[/FONT]<wbr style="font-family: arial, sans-serif; font-size: 12.8000001907349px;">[FONT=arial]PpSaveAsFileType=[/FONT]<wbr style="font-family: arial, sans-serif; font-size: 12.8000001907349px;">[FONT=arial]ppSaveAsPresentation,[/FONT]<wbr style="font-family: arial, sans-serif; font-size: 12.8000001907349px;">[FONT=arial]msoTristate=msoTriStateMixed)[/FONT]
[FONT=arial]        MsgBox "File was saved"[/FONT]
[FONT=arial]    Else[/FONT]
[FONT=arial]        MsgBox "try again"[/FONT]
[FONT=arial]   End If[/FONT]
[FONT=arial]End With[/FONT]
[FONT=arial]Set fd = Nothing
[/FONT][COLOR=#000000][FONT=Courier New]
end Sub[/FONT][/COLOR]
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,148,108
Messages
5,744,874
Members
423,907
Latest member
zerocool88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top