Peltier Technical Services, Inc.
 

Excel Chart Add-Ins | Training | Charts and Tutorials | Peltier Tech Blog


Peltier Tech Chart Utility

 

Excel Dashboards

 

Books at Amazon.com

 

Visual Basic Scripting (VBS)


 

VBS is a watered down version of VB/VBA that can run stand-alone on a machine with Windows Scripting Host installed. It must be hard to find a computer without WSH nowadays, because the last few versions of IE and Windows install WSH by default.

I don't use a lot of these scripts, but the examples below show how handy they can be. The examples are virtually identical, sorry for the repetition, but I just copied the scripts from my own hard drive.

XLcheck

This script tells you if Excel is running, and makes the first instance it finds visible. Copy this code into a text file, and save it in a convenient folder or on your desktop with a name like 'XLcheck.vbs'. When you think you've left an invisible instance of Excel running, run this (by double clicking) to make it visible, so you can deal with it.

' XLcheck.vbs
' Find an invisible instance of Excel
' from Rob Bruce

Dim objXL, strMessage

On Error Resume Next

' Try to grab a running instance of Excel:
Set objXL = GetObject(, "Excel.Application")

' What have we found?
If Not TypeName(objXL) = "Empty" Then
    strMessage = "Excel Running."
Else
    strMessage = "Excel Not Running."
End If

'  Feedback to user...
MsgBox strMessage, vbInformation, "Excel Status"

' Make it show so we can kill it
if strMessage = "Excel Running." then objXL.Visible = true

' End of VBS code

WDcheck

This script tells you if Word is running, and makes the first instance it finds visible. Copy this code into a text file, and save it in a convenient folder or on your desktop with a name like 'WDcheck.vbs'. When you think you've left an invisible instance of Word running, run this (by double clicking) to make it visible, so you can deal with it.

' WDcheck.vbs
' Find an invisible instance of Word
' from Coleen Christensen

Dim objWD
Dim strMessage
On Error Resume Next

' Try to grab a running instance of Word...
Set objWD = GetObject(, "Word.Application")

'  What did we find?..
If Not TypeName(objWD) = "Empty" Then
     strMessage = "Word Running."
Else
     strMessage = "Word Not Running."
End If

'  Feedback to user...
MsgBox strMessage, vbInformation, "Word Status"

'  Make the Word instance visible if we found one
If strMessage = "Word Running." then objWD.Visible = true

' End of vbs code

PPTcheck

This script tells you if PowerPoint is running, and makes the first instance it finds visible. Copy this code into a text file, and save it in a convenient folder or on your desktop with a name like 'PPTcheck.vbs'. When you think you've left an invisible instance of PowerPoint running, run this (by double clicking) to make it visible, so you can deal with it.

' PPTcheck.vbs
' Find an invisible instance of PowerPoint
' adapted from Rob Bruce (XL) & Coleen Christensen (WD)

Dim objPPT, strMessage

On Error Resume Next

' Try to grab a running instance of PowerPoint...
Set objPPT = GetObject(, "PowerPoint.Application")

' Did we find anything...?
If Not TypeName(objPPT) = "Empty" Then
    strMessage = "PowerPoint Running."
Else
    strMessage = "PowerPoint Not Running."
End If

' Tell the user what we found
MsgBox strMessage, vbInformation, "PowerPoint Status"

' Make it visible so we can close it
if strMessage = "PowerPoint Running." then objPPT.Visible = true

' End of vbs code

 

 

Page copy protected against web site content infringement by Copyscape

 

Peltier Tech Chart Utility

 

Create Excel dashboards quickly with Plug-N-Play reports.


Peltier Technical Services, Inc.

Excel Chart Add-Ins | Training | Charts and Tutorials | PTS Blog

Peltier Technical Services, Inc., Copyright © 2014. All rights reserved.
You may link to this article or portions of it on your site, but copying is prohibited without permission of Peltier Technical Services.

Microsoft Most Valuable Professional

Microsoft Most Valuable Professional

My MVP Profile