[python-win32] VBA MACRO and Python

Michael Pearmain Michael.Pearmain at tangozebra.com
Fri Oct 13 13:15:05 CEST 2006


Hi I'm a beginner to python and VBA,

However I have made a VBA macro which takes tables in excel and creates an PowerPoint slideshow,

I want to automate this process using python

The trouble I have is that the name of the file I'm running this on changes all the time, but I have saved the macro , so I want to apply the macro from one file onto the file with all the tables in? Make sense?

Below is the code I've written but I keep getting errors, can anyone offer advice please?

Much appreciated

Mike

 import win32com.client
 xl = win32com.client.Dispatch("Excel.Application")
 ppt = win32com.client.Dispatch("PowerPoint.Application")
 xl.Visible = 1 #open MS Excel
 ppt.Visible = 1 #open MS Powerpoint

#Open the work book big output (file I want ot run the macro on
 xl.Workbooks.Open('Z:\\projects\\surveys\\SPSS - Generic files\\big output.xls')
# Load the macro to use
 xl.Workbooks.Open('Z:\\projects\\surveys\\SPSS - Generic files\\ChartsToPresentation.xla')
# now try and run macro on big output, this is where it fails
 xl.Application.ExecuteExcel4Macro("weightedtables!ChartsToPresentation()""[big output.XLS]Sheet1")
  


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20061013/83532c56/attachment.html 


More information about the Python-win32 mailing list