Peltier Technical Services, Inc.
 

Peltier Technical Services, Inc.
- Custom Excel Solutions

PTS Blog: Charts and Things

Jon's Excel and Charting Pages
- Jon's Charts - Tutorials - Excel
- Site Index and Search - RSS


PTS Utilities

Commercial Utilities developed by Peltier Technical Services

  Waterfall Chart
  Box and Whisker
 

Excel Books

Books that I own and use while developing in Excel

Goods and Services

Excel or charting related products and services which I use or feel are worthwhile additions

 

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

 

 

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


Peltier Technical Services, Inc.
We can customize or automate any example from this site, or build a new one for you. To discuss your project or obtain a quote, please contact me at jonxlmvp@peltiertech.com

PTS Blog: Charts and Things

Jon's Excel and Charting Pages
- Jon's Charts - Tutorials - Excel - Site Index and Search - RSS

Peltier Technical Services, Inc., Copyright © 2008. 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