Sign in to follow this  
Followers 0
digiworks

PowerPoint Presentation to HTML

7 posts in this topic

After using this site as a guest for months, I finally ran across something I couldn't find.. I'm using the following script to convert PowerPoint Presentations into HTML pages because the option was removed in Office 2010. Initially I was using VBA within PowerPoint to save the files, but it wasn't very user-friendly (I need my co-workers to be able to use it). I googled around and got a VB script doing it, but I don't really know anything about VB, so I turned to autoit.. I ran what I had found through this awesome and turned it into a function. The problem I've run into is that with the removal of the "save as web page" option in 2010 they also removed the ways of changing web formatting.. Specifically I want to remove the navigation bars from the presentation before converting it.. I found VBA to do so but I have no experience working with it.. If anyone who knows how to incorporate this into the main script, I would greatly appreciate some help!

This is what I got out of PowerPoint's VBA help files..

With Presentations(2)
    .WebOptions.IncludeNavigation = msoFalse
End With

and here is my main script

#include <File.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>

$GUI = GUICreate("PP to HTML Converter", 300, 65, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
$convertbutton = GUICtrlCreateButton("Convert", 0, 30, 297)
$browse = GUICtrlCreateButton("Browse...", 245, 4, -1, 22)
GUICtrlSetOnEvent($browse, "browse")
GUICtrlSetOnEvent($convertbutton, "convert")
GUICtrlCreateLabel("File to Convert:", 1, 7)
$file = GUICtrlCreateInput("", 80, 5, 160, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd]", "")
$aWin = WinGetPos($GUI)
$slider = GUICtrlCreateSlider ( 1, 205, -1, 30)
WinMove($GUI, "", @DesktopWidth - $aWin[2] - 4, @DesktopHeight - $aWin[3] - $aTaskbar[3] - 4)
GUISetState(@SW_SHOW)
Dim $szDrive, $szDir, $szFName, $szExt
Global $file

Func browse()
$openpath = FileOpenDialog("Select a file", "C:\", "PowerPoint Presentations (*.ppt)", 1 + 8)
GUICtrlSetData($file, $openpath)
EndFunc

Func convert()
$openpath = GUICtrlRead($file)
_PathSplit($openpath, $szDrive, $szDir, $szFName, $szExt)
$strippedname = StringStripWS($szFName, 8)
DirCreate($szDrive & $szDir & $strippedname)
$save = $szDrive & $szDir & $strippedname & "\" & $strippedname
Dim $AppPowerPoint
Dim $OpenPresentation
Const $ppSaveAsHTML = 12
$AppPowerPoint = ObjCreate("PowerPoint.Application")
$AppPowerPoint.Visible = 1
$OpenPresentation = $AppPowerPoint.Presentations.Open(GUICtrlRead($file))  
$OpenPresentation.SaveAs ($save, $ppSaveAsHTML)
$OpenPresentation.Close ()
$AppPowerPoint.Quit ()
cls()
EndFunc

Func cls()
GUICtrlSetData($file, "")
EndFunc

Func quit()
Exit
EndFunc

While 1
sleep(1000)
WEnd

So if anyone could translate that bit of VB, I think this project will be complete! Any tips and tricks would be great as well, as I always find something new to learn with every project.

ps. Sorry for the ugly code :)

Share this post


Link to post
Share on other sites



How about using AutoIt to send the keystrokes shown here?


Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Share this post


Link to post
Share on other sites

I considered using that method, but I'd rather avoid sending keystrokes.. I was hoping to be able to slip the .WebOptions.IncludeNavigation = msoFalse into the script itself.. Thank you for the suggestion however!

Share this post


Link to post
Share on other sites

I'm not in my office at the moment and so I'm not sure if this can be done using PowerPoint.

Start recording a Macro and then convert your presentation to HTML. Stop the recording and check the generated VBA code.

It should be easy to convert the macrot to AutoIt.

BTW: IIR there is a PowerPoint UDF available on the forum.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Alright, I'll try that. I did find the PowerPoint UDF, but I couldn't find functions for changing options like that

Share this post


Link to post
Share on other sites

I don't use PPT 2010 so can only offer suggestions. How about adding a line like something you've already got?

$AppPowerPoint.Presentations(2).WebOptions.IncludeNavigation = msoFalse

Again, I don't use it, but maybe it might point you in the right direction.


Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Share this post


Link to post
Share on other sites

Working! I don't know if this is really the best way of doing this, but I added this to it, and now it works

With $OpenPresentation.WebOptions()
.IncludeNavigation = 0
EndWith

0 meaning without a navigation bar and 1 meaning with a navigation bar

Thank you both for your help! Here is the working script, for anyone who might find it useful in the future:

#include <File.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
$GUI = GUICreate("PP to HTML Converter", 300, 65, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
$convertbutton = GUICtrlCreateButton("Convert", 0, 30, 297)
$browse = GUICtrlCreateButton("Browse...", 245, 4, -1, 22)
GUICtrlSetOnEvent($browse, "browse")
GUICtrlSetOnEvent($convertbutton, "convert")
GUICtrlCreateLabel("File to Convert:", 1, 7)
$file = GUICtrlCreateInput("", 80, 5, 160, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd]", "")
$aWin = WinGetPos($GUI)
$slider = GUICtrlCreateSlider ( 1, 205, -1, 30)
WinMove($GUI, "", @DesktopWidth - $aWin[2] - 4, @DesktopHeight - $aWin[3] - $aTaskbar[3] - 4)
GUISetState(@SW_SHOW)
Dim $szDrive, $szDir, $szFName, $szExt
Global $file
Func browse()
 $openpath = FileOpenDialog("Select a file", "C:", "PowerPoint Presentations (*.ppt)", 1 + 8)
 GUICtrlSetData($file, $openpath)
EndFunc
Func convert()
$openpath = GUICtrlRead($file)
_PathSplit($openpath, $szDrive, $szDir, $szFName, $szExt)
$strippedname = StringStripWS($szFName, 8)
DirCreate($szDrive & $szDir & $strippedname)
$save = $szDrive & $szDir & $strippedname & "" & $strippedname
Dim $AppPowerPoint 
Dim $OpenPresentation
Const $ppSaveAsHTML = 12
$AppPowerPoint = ObjCreate("PowerPoint.Application")
$AppPowerPoint.Visible = 1
$OpenPresentation = $AppPowerPoint.Presentations.Open(GUICtrlRead($file))
With $OpenPresentation.WebOptions()
.IncludeNavigation = 0
EndWith
$OpenPresentation.SaveAs ($save, $ppSaveAsHTML)
$OpenPresentation.Close ()
$AppPowerPoint.Quit ()
cls()
EndFunc
Func cls()
 GUICtrlSetData($file, "")
EndFunc
Func quit()
 Exit
EndFunc
While 1
 sleep(1000)
WEnd

Thanks again!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0