[python-win32] Unable to set an Excel chart's title through win32com : can you reproduce this problem ?

2005-06-28 Thread Capiez Fabrice
Hello List,
I have searched the internet and this list's archives
without success before writing this email. I apologise in
advance if I neglected something 

obvious. (I googled the list's archives with Excel and
chart as keywords)

My problem is that I want to create or modify the title of
an Excel chart through win32com, as well as axes labels.
I am quite new to win32com and was initially enthousiastic
about being able to take VBA out of my project, doing
everything in python. 
Before starting to rewrite all the code plus some new
features in python, I did a few tests and managed
successfuly to create some charts, add and 

remove series etc. These tests showing good promised, I
entered the main phase of my project, leaving all the
cosmetics bits for the end. Now I 

need to take care of the afore-said cosmetic bits and just
found out I could not access a chart's title which
jeopardises the whole thing.

The details are given underneath. My question is : is
this a problem with win32com that cannot access all the
chart object's feantures ? or is it a 

problem with my system ? or am I doing somethin altogether
wrong ? 


here is a sample of code that reproduces the error on my
computer : 

# coding=utf8
import win32com.client 
from win32com.client import constants
import random
import pythoncom

xlApp = win32com.client.Dispatch(Excel.Application)
xlApp.Visible = 1
wb=xlApp.Workbooks.Add()
sheet = wb.Sheets(1)
sheet.Name=toto
for i in range (25) :
a=sheet.Cells(4+i,1)
a.Value=i
a=sheet.Cells(4+i,2)
a.Value=i**0.5*random.random()

chart = wb.Charts.Add()
chart.ChartType = constants.xlXYScatterSmoothNoMarkers
chart.Name = Test 
series = chart.SeriesCollection().NewSeries()
Xval=sheet.Range(A4:A28)
Yval=sheet.Range(B4:B28)
series.XValues = Xval
series.Values = Yval
series.Name = Data
xAxis = chart.Axes()[0]
yAxis = chart.Axes()[1]
xAxis.HasMajorGridlines = True
yAxis.HasMajorGridlines = True
chart.Location (Where=constants.xlLocationAsObject,
Name=sheet.Name)
try:
chart.HasTitle = True
chart.ChartTitle.Characters.Text =title

except pythoncom.com_error, (hr,msg,exc,arg):
print Excel failed with code %d: %s
%(hr,msg)
if exc is None:
print No extended information
else :
   
wcode,source,text,helpFile,HelpId,scode=exc
print the source of error is, source
print message :, text


The following produces:

Excel failed with code -2146827864: OLE error 0x800a01a8
No extended information

The same error occurs if I try to set an axis title
instead of the chart's title. It also occurs whether I
first set chart.HasTitle to True or not. I 

checked the chart object's model and I am using the method
names given by the analysis of a VBA macro. 

The error occurs whether I use early or late binding (I
tried once to add .dynamic. before the Dispatch method)

Actually, this is not all, I discovered another side
effect :
Not being able to set the title and axis labels from
Python, I decided to create some blank charts as templates
with proper titles and labels and then 

import them, copy the sheet in my active workbook and
insert my data series in them. This works as far as
inserting the series is concerned, but the 

Axis labels are lost when copying the template sheet in
the current workbook (template.Copy(Before=sheet)).
Actually, the result is quite erratic 

since some Axis Labels are sometimes kept intact. (I have
12 charts on my template and sometimes the 12 charts loose
their labels, sometimes 2 or 

3 manage to keep them in the copy process).

So that brings me back to my initial request : could
someone try to reproduce the problem to see whether it has
something to do with win32com 

that might not be able to access all legal methods or
whether it is something on my system. By the way, I am
using a Japanese system which 

explains the  # coding=utf8 at the begining of the
script and might also be a source of problems.

I hope that someone is able to give me some insight on
this

Best Regards,

Fabrice Capiez


__
Save the earth
http://pr.mail.yahoo.co.jp/ondanka/

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] failure in makepy.py

2005-06-28 Thread Fitzhugh, Cary








I think I found the issue.



There is some issue with dos file formats which caused my
python interpreter to give a syntax error.

Opened it in Gvim, saved in unix format, now it works fine..



Weird.

Sorry to bug you all.

Cary






___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Python-win32 Digest, Vol 27, Issue 34

2005-06-28 Thread Tony C

I would think a better approach would be to instantiate multiple instances like this.
Have you tried something like this?

lv1 = win32com.client.Dispatch(LabVIEW.Application)
lv2 = win32com.client.Dispatch(LabVIEW.Application)




hi,

anybody has called two VIs in parallel??

somehow like this:
**
***import win32com.clientimport threadlv = win32com.client.Dispatch(LabVIEW.Application)def start():  vi2 = lv.GetVIReference(p2.vi)  vi2.Run()thr = thread.start_new_thread(start, ())vi1 = lv.GetVIReference(p1.vi)vi1.Run()
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Unable to set an Excel chart's title through win32com : can you reproduce this problem ?

2005-06-28 Thread Tim Roberts
On Tue, 28 Jun 2005 18:03:17 +0900 (JST), Capiez Fabrice 
[EMAIL PROTECTED] wrote:

Hello List,
I have searched the internet and this list's archives
without success before writing this email. I apologise in
advance if I neglected something obvious. (I googled the list's archives with 
Excel and
chart as keywords)
  


Did you look for ChartTitle?  That would be the sensible query, 
although I don't think it would have helped here.

The details are given underneath. My question is : is
this a problem with win32com that cannot access all the
chart object's feantures ? or is it a 
problem with my system ? or am I doing somethin altogether
wrong ? 


here is a sample of code that reproduces the error on my
computer : 

# coding=utf8
import win32com.client 
from win32com.client import constants
import random
import pythoncom

xlApp = win32com.client.Dispatch(Excel.Application)
xlApp.Visible = 1
wb=xlApp.Workbooks.Add()
sheet = wb.Sheets(1)
sheet.Name=toto
for i in range (25) :
a=sheet.Cells(4+i,1)
a.Value=i
a=sheet.Cells(4+i,2)
a.Value=i**0.5*random.random()

chart = wb.Charts.Add()
chart.ChartType = constants.xlXYScatterSmoothNoMarkers
chart.Name = Test 
series = chart.SeriesCollection().NewSeries()
Xval=sheet.Range(A4:A28)
Yval=sheet.Range(B4:B28)
series.XValues = Xval
series.Values = Yval
series.Name = Data
xAxis = chart.Axes()[0]
yAxis = chart.Axes()[1]
xAxis.HasMajorGridlines = True
yAxis.HasMajorGridlines = True
chart.Location (Where=constants.xlLocationAsObject,
Name=sheet.Name)
try:
chart.HasTitle = True
chart.ChartTitle.Characters.Text =title
  


Was the .Characters here an experiment?  You should remove that.  Text 
is a property of the ChartTitle object.


except pythoncom.com_error, (hr,msg,exc,arg):
print Excel failed with code %d: %s
%(hr,msg)
if exc is None:
print No extended information
else :
   
wcode,source,text,helpFile,HelpId,scode=exc
print the source of error is, source
print message :, text


The following produces:

Excel failed with code -2146827864: OLE error 0x800a01a8
No extended information



Error 800a01a8 is object required.  COM thinks that the chart object 
is no longer an object.

Your try/except was masking the real problem.  You thought the issue was 
with chart.ChartTitle, but if you had eliminated the try/except and 
allowed the normal error processing to occur, you would have seen that 
the error was, in fact, occurring at the chart.HasTitle.

I'm not sure I know why, but the issue is the chart.Location method.  
After that method, the chart object is no longer valid, and you can't 
manipulate anything.  If you move the chart.Location call to the end, 
it works as expected:

...
xAxis.HasMajorGridlines = True
yAxis.HasMajorGridlines = True
chart.HasTitle = True
chart.ChartTitle.Text =title
chart.Location (Where=constants.xlLocationAsObject, Name=sheet.Name)

-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza  Boekelheide, Inc.

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Failure in makepy.py

2005-06-28 Thread Mark Hammond
This sounds like a bug in Python 2.4 and you are using ActivePython.  The
recent pywin32 builds have a work-around for this problem, but ActivePython
was built before this was in place.
 
Mark

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Fitzhugh, Cary
Sent: Wednesday, 29 June 2005 12:58 AM
To: python-win32@python.org
Subject: [python-win32] Failure in makepy.py



Hi all,

 

I'm trying to get connected to Rhapsody 6.0 and found the rhapsody.tlb.  

If I try to run makepy on it, it gives me a Syntax Error on line 206.  I
guess I can paste the info...

 

python c:\Python24\Lib\site-packages\win32com\client\makepy.py
c:\Rhapsody60\rhapsody.tlb  c:\Documents and
Settings\cary.fitzhugh\working\xmitomdl\rhap60.py

Generating to
C:\Python24\lib\site-packages\win32com\gen_py\47DBF9D5-F318-11D2-B825-00104B
3E6572x0x1x0\__init__.py

Building definitions from type library...

Generating...

Importing module

Traceback (most recent call last):

  File c:\Python24\Lib\site-packages\win32com\client\makepy.py, line 370,
in ?

 

rc = main()

  File c:\Python24\Lib\site-packages\win32com\client\makepy.py, line 363,
in main

GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, bForDemand
= bForDemand, bBuildHidden = hiddenSpec)

  File c:\Python24\Lib\site-packages\win32com\client\makepy.py, line 274,
in GenerateFromTypeLibSpec

gencache.AddModuleToCache(info.clsid, info.lcid, info.major, info.minor)

  File C:\Python24\Lib\site-packages\win32com\client\gencache.py, line
555, in

 AddModuleToCache

mod = _GetModule(fname)

  File C:\Python24\Lib\site-packages\win32com\client\gencache.py, line
634, in

 _GetModule

mod = __import__(mod_name)

  File
C:\Python24\lib\site-packages\win32com\gen_py\47DBF9D5-F318-11D2-B825-00104
B3E6572x0x1x0\__init__.py, line 206

'{AB75C7F8-145D-439E-B02A-9E40E1807754}' : 'IRPRequirement',

  ^

SyntaxError: invalid syntax

 

I'm hoping someone has seen something similar.  

 

Any ideas?

 

Thanks.

Cary

attachment: winmail.dat___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32