I followed the example in http://stompstompstomp.com/weblog/technical/2004-05-20 and learned that to
add a new worksheet to an Excel workbook, you would use the
workbook.Worksheets.Add() method. That works. However, the new worksheet
got added *in front* of the last worksheet I was at. How can I get it to
add *after*?
Thanks,
--
Me 12 1863
I am not sure about this but I believe you can give a parameter
after="sheet1". to Add(), like so, Add(after="sheet1").
Unfortunately I do not have Excel installed on this machine to confirm
this.
A tip: if you have VBA (which you should if you have Excel) installed,
lookup the Add method for the Worksheets collection. VBA will show the
code completion, with all the arguments for the method call. Try the
same for any of the methods.
Thanks,
--Kartic
"Kartic" <ka******************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com... I am not sure about this but I believe you can give a parameter after="sheet1". to Add(), like so, Add(after="sheet1").
I get a "got an expected keyword argument 'after'" from Add().
Unfortunately I do not have Excel installed on this machine to confirm this.
A tip: if you have VBA (which you should if you have Excel) installed, lookup the Add method for the Worksheets collection. VBA will show the code completion, with all the arguments for the method call. Try the same for any of the methods.
Yes, I read about that but unfortunately I have no experience with VBA *at
all*. :=(
Thanks, --Kartic
Ah, this work:
self.xlbook.Worksheets.Add(None,sht)
got it from: http://mail.python.org/pipermail/pyt...er/183367.html
Thanks again.
--
Me
"It's me" <it***@yahoo.com> wrote in message
news:ou****************@newssvr21.news.prodigy.com ... "Kartic" <ka******************@gmail.com> wrote in message news:11**********************@f14g2000cwb.googlegr oups.com... I am not sure about this but I believe you can give a parameter after="sheet1". to Add(), like so, Add(after="sheet1").
I get a "got an expected keyword argument 'after'" from Add().
Unfortunately I do not have Excel installed on this machine to confirm this.
A tip: if you have VBA (which you should if you have Excel) installed, lookup the Add method for the Worksheets collection. VBA will show the code completion, with all the arguments for the method call. Try the same for any of the methods.
Yes, I read about that but unfortunately I have no experience with VBA *at all*. :=(
Thanks, --Kartic
It's me wrote: I followed the example in http://stompstompstomp.com/weblog/technical/2004-05-20 and learned that to add a new worksheet to an Excel workbook, you would use the workbook.Worksheets.Add() method. That works. However, the new worksheet got added *in front* of the last worksheet I was at. How can I get it to add *after*?
Thanks,
-- Me
Hello,
I did it yesterday like this way and it works well (part of my code):
wb.Worksheets.Add(Count=nrMonths,After=wb.Workshee ts(1))
As I read in MSDN you could not write After="sheet1" instead you must
use the Object of sheet1 like in my example and it works well in my
case. The Count=... statement will create n Sheets after the first worksheet
By
Marten
"Marten Bauer" <Ma**********@gmx.net> wrote in message
news:34*************@individual.net... I did it yesterday like this way and it works well (part of my code):
wb.Worksheets.Add(Count=nrMonths,After=wb.Workshee ts(1))
As I read in MSDN you could not write After="sheet1" instead you must use the Object of sheet1 like in my example and it works well in my case. The Count=... statement will create n Sheets after the first
worksheet
Yes, I learn that as well. The parameter to After is a Worksheet object.
It appears if you don't specify any parameters, it would add it Before the
current sheet.
Thanks, By Marten
"It's me" <it***@yahoo.com> writes: Yes, I read about that but unfortunately I have no experience with VBA *at all*. :=(
You don't really have to know VBA, but if you're going to try to
interact with COM objects from Python, you'll find it much smoother if
you at least use any available reference information for the COM
object model and interfaces you are using.
In the Excel case, that means understanding - or at least knowing how
to look in a reference - its object model, since that will tell you
exactly what parameters an Add method on a worksheet object will take
and how they work.
For excel, online documentation can be found in a VBAXL9.CHM help file
(the "9" may differ based on Excel release), but it might not always
be installed depending on what options were selected on your system. In
my English, Office 2000 installation, for example, the files are located in:
c:\Program Files\Microsoft Office\Office\1033
You can load that file directly, or Excel itself will reference it
from within the script editor help (Tools->Macro->Visual Basic Editor,
then F1 for help). If you methods or classes and have the help
installed it'll bring in the reference.
You can also find it on MSDN on the web, although it can be tricky to
navigate down to the right section - the top of the Office 2000 object
documentation should be available at: http://msdn.microsoft.com/library/en...modelguide.asp
This is mostly reference information, but there are some higher level
discussions of overall objects (e.g., worksheets, workbooks, cells,
etc...) too.
-- David
Thanks,
"David Bolen" <db**@fitlinxx.com> wrote in message
news:u1***********@fitlinxx.com... "It's me" <it***@yahoo.com> writes:
Yes, I read about that but unfortunately I have no experience with VBA
*at all*. :=( You don't really have to know VBA, but if you're going to try to interact with COM objects from Python, you'll find it much smoother if you at least use any available reference information for the COM object model and interfaces you are using.
In the Excel case, that means understanding - or at least knowing how to look in a reference - its object model, since that will tell you exactly what parameters an Add method on a worksheet object will take and how they work.
For excel, online documentation can be found in a VBAXL9.CHM help file (the "9" may differ based on Excel release), but it might not always be installed depending on what options were selected on your system. In my English, Office 2000 installation, for example, the files are located
in: c:\Program Files\Microsoft Office\Office\1033
You can load that file directly, or Excel itself will reference it from within the script editor help (Tools->Macro->Visual Basic Editor, then F1 for help). If you methods or classes and have the help installed it'll bring in the reference.
You can also find it on MSDN on the web, although it can be tricky to navigate down to the right section - the top of the Office 2000 object documentation should be available at:
http://msdn.microsoft.com/library/en...modelguide.asp This is mostly reference information, but there are some higher level discussions of overall objects (e.g., worksheets, workbooks, cells, etc...) too.
-- David
Yes, Mike,
Others pointed that out as well.
The difficulty is that they are all in VBAs. Most of them can be
translated to Python fairly easily, and some I can get from looking at the
recorded macro - but some requires quite a bit of head scratching.
For instance, I wanted to figure out how create a new window. So, I went
through the record macro process and looked at the VBA code, it says:
ActiveWindow.NewWindow
Okay. Now what???
And for switching window, it says:
Windows("Book1:1").Activate
Okay. ???
So, I look through the online information on msdn and viola! No mentioning
of that anwhere....
Would be nice if there's a Python specific of it....but just dreaming...
Back to reading MSDN.....
Thanks,
"Mike Thompson" <none.by.e-mail> wrote in message
news:41**********************@news.optusnet.com.au ... It's me wrote: I followed the example in http://stompstompstomp.com/weblog/technical/2004-05-20 and learned that
to add a new worksheet to an Excel workbook, you would use the workbook.Worksheets.Add() method. That works. However, the new
worksheet got added *in front* of the last worksheet I was at. How can I get it
to add *after*?
Thanks,
-- Me
Does this help?
http://msdn.microsoft.com/library/de...nworkbooks.asp -- Mike
It's me wrote: Yes, Mike,
Others pointed that out as well.
For good reason. The difficulty is that they are all in VBAs. Most of them can be translated to Python fairly easily, and some I can get from looking at the recorded macro - but some requires quite a bit of head scratching.
For instance, I wanted to figure out how create a new window. So, I went through the record macro process and looked at the VBA code, it says:
ActiveWindow.NewWindow
app.ActiveWindow.NewWindow() Okay. Now what???
And for switching window, it says:
Windows("Book1:1").Activate
app.Windows.Item("Book1:1").Activate()
---------------------------------------------------------------------
from win32com.client import Dispatch, constants
app = Dispatch("Excel.Application")
app.Visible = True
workbook = app.Workbooks.Add()
defaultWorksheet = workbook.Worksheets(1)
app.ActiveWindow.NewWindow()
app.ActiveWindow.NewWindow()
# grab the capation (like 'Book1:1') from one of the windows
thridWindowsCaption = app.Windows[2].Caption
print thridWindowsCaption
app.Windows.Item(thridWindowsCaption).Activate()
------------------------------------------------------------------------
Sometimes its useful to look in the file generated by makepy. It details
all the classes and their methods AND there are annotations in the form
of comments. Having said that, if you've never looked in a makepy
generated module before, you're in for a shock - it takes a while
before you figure out what you are looking at.
When you get stuck, trial & error and a good debuger are your friend.
--
Mike
Okay, thanks. That helps a lot.
"Mike Thompson" <none.by.e-mail> wrote in message
news:41**********************@news.optusnet.com.au ... It's me wrote: Yes, Mike,
Others pointed that out as well.
For good reason.
The difficulty is that they are all in VBAs. Most of them can be translated to Python fairly easily, and some I can get from looking at
the recorded macro - but some requires quite a bit of head scratching.
For instance, I wanted to figure out how create a new window. So, I
went through the record macro process and looked at the VBA code, it says:
ActiveWindow.NewWindow
app.ActiveWindow.NewWindow()
Okay. Now what???
And for switching window, it says:
Windows("Book1:1").Activate
app.Windows.Item("Book1:1").Activate()
---------------------------------------------------------------------
from win32com.client import Dispatch, constants
app = Dispatch("Excel.Application") app.Visible = True
workbook = app.Workbooks.Add()
defaultWorksheet = workbook.Worksheets(1)
app.ActiveWindow.NewWindow() app.ActiveWindow.NewWindow()
# grab the capation (like 'Book1:1') from one of the windows thridWindowsCaption = app.Windows[2].Caption
print thridWindowsCaption app.Windows.Item(thridWindowsCaption).Activate()
------------------------------------------------------------------------
Sometimes its useful to look in the file generated by makepy. It details all the classes and their methods AND there are annotations in the form of comments. Having said that, if you've never looked in a makepy generated module before, you're in for a shock - it takes a while before you figure out what you are looking at.
When you get stuck, trial & error and a good debuger are your friend.
-- Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: quadric |
last post by:
Hi,
I am just getting into PythonWin. I need my application that has Python
embedded within it
to communicate with an Excel spreadsheet. I have done this manually with
PythonWin.
All works...
|
by: Jive |
last post by:
I've un-installed Python 2.4, re-installed Python 2.3 and PythonWin for 2.3,
but it's still broke.
When I start PythonWin, sometimes it looks like it is going to be okay. But
as soon as I open...
|
by: tkpmep |
last post by:
I have a Python program that collects user input using
msg = "Enter the full path and name of the file to be processed: "
answer = raw_input(msg)
If I run it in IDLE, the question is splashed...
|
by: siggy2 |
last post by:
Hi All,
(sorry for my bad english)
I wrote a __tiny__ and __stupid__ recursive script directly into
pythonwin
interactive window with a time.sleep(1) and a print before each
recursion...
I...
|
by: Robert |
last post by:
Hello,
I'm using Pythonwin and py2.3 (py2.4). I did not come clear with this:
I want to use win32-fuctions like win32ui.MessageBox,
listctrl.InsertItem ..... to get unicode strings on the...
|
by: Dan |
last post by:
Just starting to do some windows Client / Server programming. Which
would you recommend? I need to create a server to fire events and
communicate with clients over a lan. Thanks
|
by: Andrea Gavana |
last post by:
Hi All,
I am having some problems in running a very simple python script,
which prints some numbers in an Excel spreadsheet. The numbers are
stored in a list. I know that the numbers are...
|
by: siggi |
last post by:
Hi all,
newbie question:
I'd like to try speech synthesis with PythonWin 2.5.
Problem
******
according to several instructions, such as found on...
|
by: sterling |
last post by:
I'm curious as to why the difference between IDLE and pythonWin when
using win32com.
opening an excel file, i've attempted to grab the chart information
out of the file.
commands like co =...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |