Michael Pearmain wrote:

>
> 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,
>

You know, you could write that macro entirely in Python without
involving VBA...

> 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?
>

When you have a problem like this, you should always tell us exactly
what the error was.  Saying "I keep getting errors" does not tell us
anything about the problem.

>  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")
>

The problem, probably, is those quotes in the middle.  I suspect you
wanted a single quotation mark in that string, but what you have here is
two strings that get concatenated, with no quote marks.  If you want a
single quotation mark, use \":
    ...ChartsToPresentation()\"[big output.XLS]...
If you want two quote marks, use \"\".

Alternatively, you could use single quotes around the string:
 
xl.Application.ExecuteExcel4macro('weightedtables!ChartsToPresentation()"[big
output.XLS]sheet1')

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

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

Reply via email to