Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Copy a formatted sheet in Excel
Replies: 9   Last Post: Jul 11, 2013 6:03 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
none3

Posts: 429
Registered: 12/4/04
Re: Copy a formatted sheet in Excel
Posted: Jan 24, 2013 3:47 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Claudio Pedrazzi" wrote in message <h8d8re$7h8$1@fred.mathworks.com>...
> I am trying to follow the advice given, but I think I have a syntax problem:
>
> I coded the following, using the examples given, and looking at a recorded macro that I made copying one sheet:
>
> excel = actxserver('excel.application');
> % open the excel file, full path need to be mentioned or else excel will pick it from most recently opened files.
> wkbk = excel.Workbooks.Open([pwd '\' DestFile]);
> wksheet = wkbk.Worksheets.Item('Form1'); % Choose desired sheet
> co=wksheet.Copy After:=Sheets(4);
> wkbk.Save % save the changes
> excel.Quit % close excel
>
> but of course the "After:=Sheets(4)"
> does not work, it is matlab syntax error: I get
> Unexpected MATLAB expression.
>
> If I code only
> co=wksheet.Copy
> I get:
> ??? One or more output arguments not assigned during call to "Copy".
>
> How do I specify the argument "After" that says after which sheet I have to copy? there is here probably some special syntax that I am missing.
>
> Any help will be very appreciated!
> Best regards
> Claudio


I realize this is a fairly old thread but I searched high and low for this answer, so in case anyone else needs this info here's how:

To put sheet1 after sheet0 use:

invoke(sheet1,'move',[],sheet0);

To put sheet1 before sheet0 use

invoke(sheet1,'move',sheet0);



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.