This worked for me.....the first function is called to create the copy, the second to format and rename it.
def create_graph (filename,graph):
#instatiate the Excel object
xl = win32com.client.Dispatch("Excel.Application")
#Open the workbook
wb = xl.Workbooks.Open (filename)
sh = wb.Sheets("charttemp")#Select the first worksheet in the workbook
try:
print graph[6]
wb.Sheets("charttemp").Copy(None, After=wb.Sheets(wb.Sheets.Count))
#Rename the new chart and put this value in a return value for subsequent reference
wb.Sheets(wb.Sheets.Count).Name = graph[6]
xl.ActiveWorkbook.Close(SaveChanges=1)
except:
xl.ActiveWorkbook.Close(SaveChanges=1)
#Quit Excel
xl.Quit
del xl
def format_chart(filename, graph):
#instatiate the Excel object
xl = win32com.client.Dispatch("Excel.Application")
#Open the workbook
wb = xl.Workbooks.Open (filename)
try:
wb.Charts(graph[6]).ChartTitle.Characters.Text=graph[0]
wb.Charts(graph[6]).Axes(1).MinimumScale=36530
#wb.Charts(graph[6]).Axes(1).MinimumScaleAuto=True
#wb.Charts(graph[6]).Axes(1).MinorUnitsAuto=True
#wb.Charts(graph[6]).Axes(1).MajorUnitsAuto=True
#wb.Charts(graph[6]).Axes(1).Crosses=xlAutomatic
xl.ActiveWorkbook.Close(SaveChanges=1)
except:
raise
xl.ActiveWorkbook.Close(SaveChanges=1)
#Quit Excel
xl.Quit
del xl
HTHT
Eric
Eric B. Powell
E&GIS
BSRI
(803)952-7783
When a true genius appears in this world you may know him by this sign, that the dunces are all in confederacy against him. (Swift)
Fabrice Capiez <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED] 06/29/2005 06:23 PM |
|
>
> According to Excel Visual Basic Help: "Characters - Returns a
> <mk:@MSITStore:C:\Program%20Files\Microsoft%20Office\Office\1033\VBAXL9.CHM::/
html/xlobjCharacters.htm>Characters
> object that represents a range of characters within the object text. You
> can use the Characters object to format characters within a text string.
>
> Now look at the Text property "Returns or sets the text for the specified
> object. Read-only String for the Range object, read/write String for all
> other objects."
>
> So try chart.ChartTitle.Text ="title"
>
Actually I tried both ChartTitle.Text and ChartTitle.Characters.Text
The VBA macro recorder uses Characters.Text to set the title but at first I
thought that this object was only due to my Japanese version of Office, so I
tried with both possibilities at every step of my testing.
Now I think that the problem lies in copying a chart from one place to
another since the problem arises with both Copy and Location methods..
Either there is a problem with win32com, or the com interface of the object
is bugged, or I am not using things the right way altogether.
Thank you for the insight anyway
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 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32