At 10:18 AM 10/3/2003, Marc wrote:
Hi all,
I am trying to write an application where I need the ability to open
an Excel spreadsheet and do basic read/write, insert rows, and
hide/unhide rows. Using win32com I have been able to get the basics
down as well as some examples displaying how to simply read and write.
But the next step appears exponential. I haven never done anything in
VB, so any and all concepts and commands are completely foreign. I
have been digging through the VB help and also bought a book
specifically for Python and COM. But I don't really have time to learn
VB before I can finish my script.
Would there happen to be any pre-existing examples of the stuff I need
to do out there? Basically I need to do the things I listed above -
insert rows and columns and hide/unhide rows. I think with a few
examples of sheet manipulation I could figure out the rest.
The Range object handles all of the above. I recommend examining the
various properties and methods of Range. One easy way to do this is
1 open the Excel VBA Window
2 press F2 to get the Object Browser
3 scroll the classes pane to Range then look at members insert, delete and
value.
4 Press F1 on any of these to see the help file and helpful examples.
Also look at Worksheet Classes Rows and Columns properties for Range
objects that span entire rows / columns
Assuming you have created a worksheet object (let's call it ws)
Reading & Writing (a review):
rng = ws.Range("a1:b2")
rng.Value
((None, None), (None, None)) rng.Value=((1, 2), (3, 4))
rng.Value
((1.0, 2.0), (3.0, 4.0))
Hiding: row = ws.Rows("1")
row.Hidden
0 row.Hidden=1
Insert/Delete row.Insert()
col = ws.Columns("A")
col.Delete()
Enough?
Bob Gailer
bg*****@alum.rpi.edu
303 442 2625
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003