[Tutor] Invoking Excel Macro

Liam Clarke ml.cyresse at gmail.com
Tue Apr 25 09:04:16 CEST 2006


Hi Arun et al,

Google says - http://support.microsoft.com/default.aspx?scid=kb;en-us;210684

"This problem can occur when you give the workbook a defined name and
then copy the worksheet several times without first saving and closing
the workbook, as in the following sample code..." (code is in above
article)

"""To resolve this problem, save and close the workbook periodically
while the copy process is occurring, as in the following sample
code""" ditto above

The issue is your macro. As such, there are some excellent Excel and
VBA related help forums on the net.

Good luck!

Regards,

Liam Clarke

On 4/25/06, Mike Hansen <mahansen at adelphia.net> wrote:
> I guess I'm confused. You mentioned that it still throws and error
> while trying to save the workbook. hmmm.... Do you get this error when
> trying to close Excel in the macro? Many times, Excel pops up a dialog
> box when closing it if there's still a workbook open even if it has
> been saved. That's where the Application.DisplayAlerts comes in. So I
> may have been a little off on the part of saving. It might be the
> closing of Excel. Other than that, I'm stumped.
>
> Mike
>
> On Apr 24, 2006, at 7:32 AM, arun wrote:
>
> > Hi Mike,
> > It doesn't display any dialog box rather it gives a temporary name
> > to the file.
> > Ex
> > newsheet.xls as newsheet1.xls
> > So i'm not able to save it. Is there an alternative to invoke the
> > macro and save the file from my script itself .(saving it through
> > macro wud be a better option : ) )
> >
> > Thanx and Regards,
> > arun
> >
> >
> > On 4/21/06, Mike Hansen <mhansen at cso.atmel.com> wrote: In the macro,
> > you might try Application.DisplayAlerts = False and reset it toTrue
> > after you save.
> >> I think it might be trying to display a dialog box before it saves.
> >>
> >> Mike
> >>
> >>> From: tutor-bounces at python.org [mailto: tutor-bounces at python.org] On
> >>> Behalf Of arun
> >>> Sent: Friday, April 21, 2006 1:44 AM
> >>> To: tutor at python.org
> >>> Subject: Re: [Tutor] Invoking Excel Macro
> >>>
> >>> I'm sorry , there is something realy wrong with 'Run-time error
> >>> 1004':. I have fixed it now but still it throws an error while
> >>> trying to save the workbook.
> >>
> >> On 4/21/06, arun <r.arunchand at gmail.com> wrote: Hi,
> >>> I tried invoking a macro from my python script and It is throwing
> >>> an error message that reads 'Run-time error 1004':
> >>>
> >>> "This operation requires the merged cells to be identically sized"
> >>>
> >>> My script looks like this
> >>>
> >>> from win32com.client import Dispatch
> >>> xl = Dispatch('Excel.Application')
> >>> xl.Workbooks.Add('E:\Templates\sample.xls')
> >>> xl.Run('Import_file') # name of the macro
> >>>
> >>> Also while (running the macro)opening the workbook itnames it as
> >>> "sample1.xls' ,and so
> >>> It says there is no such file sample.xls
> >>>
> >>> "
> >>> Filename = Myexcel.xls
> >>> Workbooks("sample.xls").SaveAs Filename
> >>> "
> >>>
> >>> Can somebody help me with this issue : (
> >>>
> >>>
> >>> Thanx
> >>> arun
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >> --
> >> arun
> >
> >
> >
> > --
> > arun_______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list