Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - How do i open Excel 2003 or 2007 from VBS

Reply
 
Old 09-18-2009   #1 (permalink)
RedV


 
 

How do i open Excel 2003 or 2007 from VBS

I have both 2003 and 2007 installed on my machine. I want to create a VB
Script to open a few files in 2003 and in 2007 versions. How can i do that?

My System SpecsSystem Spec
Old 09-18-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: How do i open Excel 2003 or 2007 from VBS


"RedV" <RedV@newsgroup> wrote in message
news:860341B7-8D6F-4227-8361-F6135080CDA1@newsgroup
Quote:

>I have both 2003 and 2007 installed on my machine. I want to create a VB
> Script to open a few files in 2003 and in 2007 versions. How can i do
> that?
VBScript code similar to below should work for either version, as long as
the 2007 version is installed on the computer where you run the script:
=============
Option Explicit
Dim objExcel, objWorkbook

Set objExcel = CreateObject("Excel.Application")

' Open either 2003 or 2007 version Excel spreadsheet.
' objExcel.Workbooks.Open "C:\Scripts\Example.xls"
objExcel.Workbooks.Open "C:\Scripts\Example.xlsx"

Set objWorkbook = objExcel.ActiveWorkbook.Worksheets(1)

' Display some specific cell values.
Wscript.Echo objWorkbook.Cells(1, 1).Value
Wscript.Echo objWorkbook.Cells(1, 2).Value
Wscript.Echo objWorkbook.Cells(2, 1).Value
Wscript.Echo objWorkbook.Cells(2, 2).Value

' Clean up.
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Can't open Excel 2007 with double click Vista General
office excel 2007 & 2003 on same computer? Microsoft Office
PowerPoint 2003 files very slow to open in 2007 on Vista Vista General
Excel 2007 display shift when open file in explorer Vista General
Excel 2007 wil not open and Excel 2007 document in Vista? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46