digiworks Posted January 31, 2012 Share Posted January 31, 2012 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 Withand here is my main scriptexpandcollapse popup#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) WEndSo 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 Link to comment Share on other sites More sharing options...
JohnQSmith Posted January 31, 2012 Share Posted January 31, 2012 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". Link to comment Share on other sites More sharing options...
digiworks Posted January 31, 2012 Author Share Posted January 31, 2012 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! Link to comment Share on other sites More sharing options...
water Posted January 31, 2012 Share Posted January 31, 2012 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki  Link to comment Share on other sites More sharing options...
digiworks Posted January 31, 2012 Author Share Posted January 31, 2012 Alright, I'll try that. I did find the PowerPoint UDF, but I couldn't find functions for changing options like that Link to comment Share on other sites More sharing options...
JohnQSmith Posted January 31, 2012 Share Posted January 31, 2012 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". Link to comment Share on other sites More sharing options...
digiworks Posted January 31, 2012 Author Share Posted January 31, 2012 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: expandcollapse popup#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! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now