Hey, Scripting Guy! Quick-Hits Friday: The Scripting Guys Respond to a Bunch of Questions (11/28/08)
“File Not Found” Error When Trying to Run a PowerPoint Presentation from the Windows XP Desktop
Hey, Scripting Guy! I have a problem when I try to run a Microsoft Office PowerPoint slideshow that I have saved on the desktop of my Windows XP computer. I cannot get this stupid thing to work. It keeps giving me a “File not found” error when I use the Run command from the Wscript.Shell object. I am at wits’ end.
There are actually two problems at work here. The first issue is that the command name for PowerPoint is not PowerPoint.exe. Unfortunately. Also unfortunately, just passing the path does not cause the PowerPoint slideshow to start and run. You need to specifically call PowerPoint with the appropriate switch. The actual executable for PowerPoint is Powerpnt.exe, which is close, but far enough away to cause you lots of pain and suffering, as well as many hours of searching to find the name. To make matters worse, and I really hate this part, if you create a shortcut to PowerPoint or right-click the properties of the shortcut, the name of the file is not displayed. This is shown here:
The way I actually found the name of the PowerPoint process was to start the slideshow, open Task Manager, and find it there. After we have found the process executable, we need to try to figure out how to make the thing start as a slideshow. The problem here is that when you start PowerPoint from the command line, it opens in editing mode by default. Using Live Search, I was able to quickly find this link, which tells me the command-line switches for Microsoft PowerPoint 2007. There are similar pages for some of the older versions of PowerPoint as well.
The second problem you were having is an issue that goes all the way back to Windows 95 and that is the issue of the space in the path to the desktop (by the way, this has been fixed in Windows Vista, where everything is in a Documents folder.) When you have a space in a file name or in the path to the file, you need to use double quotation marks around the path. Here is an example:
""C:\Documents and Settings\ed\Desktop\Bonjour.ppsx""
If we put all this newfound knowledge together, we come up with this script (we’ll call it StartPowerPointSlideShow.vbs):
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run("powerpnt.exe /s ""C:\Documents and Settings\ed\Desktop\Bonjour.ppsx"" ")
Can Word Create a Backup of a File Every Time I Save It?
Hey, Scripting Guy! I need to configure Word to automatically create a backup of a file when it saves the file. Help?
Try the SetWordBackUpFeatures.vbs script, which follows this paragraph. The first thing we do is create an instance of the Word.Application object. We make it visible, add a document, create a selection object, and add a little bit of text. We then use the options property of the word.application object to return an instance of the options object. After you have an options object, you specify the createBackup property to true. Two things to keep in mind: fast save and create backup options are mutually exclusive. To make sure the script works, we specifically turn one off and the other one on. We then save the copy of our document. The second time the script is run, you will see the backup copy of the file.
Set objWord = CreateObject("Word.Application")
objWord.visible = True
Set wordDoc = objWord.Documents.add()
Set selection = objword.selection
Set options = objWord.Options
options.AllowFastSave = False
options.CreateBackup = True
How Can I Create an HTML Application for an Excel Spreadsheet?
Hey, Scripting Guy! I have a Microsoft Office Excel spreadsheet that contains a list of applications in the first column. I would like to be able to present the list of applications to users via a drop-down list. How can I do this?
It sounds as if you are thinking of creating an HTML Application (HTA). Here are some resources to help you get started: http://www.microsoft.com/technet/scriptcenter/hubs/htas.mspx.
You might also be interested in some of the resources we have for reading Excel:
Don’t forget the Script Repository: http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true. You will also find a good collection of Excel scripts in the Community-Submitted Script Center: http://www.microsoft.com/technet/scriptcenter/csc/scripts/office/default.mspx.
How Can I Open Multiple Web Sites in Internet Explorer 7, Each on Its Own Tab?
Hey, Scripting Guy! I want to write a script that will open multiple Web sites in their own tabs in Internet Explorer 7. I know how to do this with some of the other browsers on the market, but I like Internet Explorer the best. Can you help me?
Yes, you can do this using Internet Explorer 7 and better. When you run the script below (we’ll call it OpenScriptCenterPages.vbs), each of the selected pages from the Script Center appears on its own tab:
Here’s the script:
TnSc = "http://search.live.com/macros/scripter/searchscriptcenter/?FORM=MACWLG"
MSDN = http://search.live.com/macros/scripter/searchmsdndocs/?FORM=OIJG
SC = http://www.microsoft.com/technet/scriptcenter/default.mspx
SR = http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true
HSG = http://www.microsoft.com/technet/scriptcenter/resources/qanda/hsgarch.mspx
OS = http://www.microsoft.com/technet/scriptcenter/resources/officetips/archive.mspx
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
'open a new window
'open url In new tab
oIE.Navigate2 MSDN, 2048
oIE.Navigate2 SC, 2048
oIE.Navigate2 SR, 2048
oIE.Navigate2 HSG, 2048
oIE.Navigate2 OS, 2048
Set oIE = Nothing
Ed Wilson and Craig Liebendorfer, Scripting Guys