Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


problems updating excel with vbs

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,51466
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> problems updating excel with vbs
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 problems updating excel with vbs - 9/3/2007 1:13:51 PM   
  gavinabrown

 

Posts: 1
Score: 0
Joined: 9/3/2007
Status: offline
Hi,
I have created a very basic script to open up a spreadsheet and to update some cells and delete some columns.  However neither action works.

Can anybody tell me where I am going wrong?

Thanks,
Gavin.


Option Explicit
Dim objExcel
Dim objSheet

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = 0
objExcel.Workbooks. Open "c:\test.xls"
Set objSheet = objExcel.ActiveWorkbook.WorkSheets(1)

Columns("AD:AH").Select
Selection.Delete Shift:=xlToLeft

objSheet.Cells(A1) = "software_brand"
objSheet.Cells(B1) = "part_type"

' Save, close, and exit.
objExcel.Application.DisplayAlerts = False
objExcel.ActiveWorkbook.SaveAs stFileNewName
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
 
 
Post #: 1
 
 RE: problems updating excel with vbs - 9/3/2007 3:37:50 PM   
  Bronk

 

Posts: 3
Score: 0
Joined: 9/10/2002
From:
Status: offline
To select a range, try
  Set objRange = objExcel.Range("A1:A5")
  objRange.Copy
or
  objExcel.Range("A1:A5").Clear

To modify contents of a cell, try
  objExcel.Range("A1").Value = "My String Value"
or
  objExcel.Cells(1, 1).Value = "My String Value"

(in reply to gavinabrown)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> problems updating excel with vbs Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts