How to record a macro within a macro

W

William C Gates

I am trying to create a macro that will allow me to save the macro within the current excel file.

When the macro is saved in the Yardi YSL template, it is removed once it isran through the Yardi software. I am trying to create this macro on a separate file that will allow the macro to be ran on the 'current selected' file after the report is ran from Yardi and save that macro to that current file (I hope this makes sense).

It's simple macro, but unable to figure out how to assign the macro to the current file, then assign it to the macro button. Once the file is saved and distributed, the 'print button' macro will work for any user.


Sheets("SEC Balance Sheet").Select
Sheets(Array("SEC Balance Sheet", "SEC Income Statement", _
"NBV-Prop Taxes by Property", "Income Stmt - Oper Props (YTD)", _
"Income Stmt - Oper Props (MTD)")).Select
Sheets("SEC Balance Sheet").Activate
Application.Dialogs(xlDialogPrint).Show
ActiveSheet.Shapes.Range(Array("Button 2")).Select
Selection.OnAction = "PrintButton"

Thank you for your help!!!
William
 
G

GS

Does it have to be in that workbook? Why not store the macro in
PERSONAL.XLS so you can reuse it whenever needed, leaving the subject
workbook macro-free?

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
W

William C Gates

Does it have to be in that workbook? Why not store the macro in

PERSONAL.XLS so you can reuse it whenever needed, leaving the subject

workbook macro-free?



--

Garry



Free usenet access at http://www.eternal-september.org

Classic VB Users Regroup!

comp.lang.basic.visual.misc

microsoft.public.vb.general.discussion


I am using that method on other macros that I use. But since this report isbeing distributed to the Executives, I want it attached to the file so there isn't any issues of accessing another file/directory; need to make it assimple and easy as possible for them to print the reports.

Thanks
William
 
C

Claus Busch

Hi William,

Am Fri, 13 Sep 2013 08:02:09 -0700 (PDT) schrieb William C Gates:
I am using that method on other macros that I use. But since this report is being distributed to the Executives, I want it attached to the file so there isn't any issues of accessing another file/directory; need to make it as simple and easy as possible for them to print the reports.

to print the whole workbook try:
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,3,,,TRUE,,FALSE)"
or:
Sheets(Array("SEC Balance Sheet", "SEC Income Statement", _
"NBV-Prop Taxes by Property", "Income Stmt - Oper Props (YTD)", _
"Income Stmt - Oper Props (MTD)")).PrintOut


Regards
Claus B.
 
G

GS

I am using that method on other macros that I use. But since this
report is being distributed to the Executives, I want it attached to
the file so there isn't any issues of accessing another
file/directory; need to make it as simple and easy as possible for
them to print the reports.

Thanks
William

Firstly, storing reusable code in working files is not considered 'good
practice'!

If your executives are using a *template* then the file they send on
should be a normal file created from the *template*! That means they'll
always have the macros in the template so long as they open a new file
based on that template.

Just curious how you intend to impliment a macro that writes a macro
the that file. Who gets this file with the macro to write the macro.
Sounds to me like you need a different approach! An addin would work
better here!

An addin can be run from any exec's machine at any time via a simple
menuitem it creates on startup (opening). The concept here keeps the
addin's project files 'clean' of macros so they can be passed around
without 'flagging' Macro Security. Since the addin will install every
time they open Excel then the macro are always available without
having to open any extra files. If the addin is stored on a network
server then each exec's computer can use it, making distribution simple
when execs are connected to the network. If they use a laptop then the
file can be copied to it and run from there instead of using the
network file.

Installing addins is done via the Addins Manager. It's a one-time task
and so should not be an issue with users to have to do it. You could
optionally use an installer to do this for them, but it would be
simpler to just do the few mouse clicks it takes.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
G

GS

so good, now we are two to encourage William to follow the right
direction
i hope that William will try XLA Add-In and also COM Add-In

That will require having access to a development language. Perhaps,
though, VSTO is an option!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
W

William C Gates

That will require having access to a development language. Perhaps,

though, VSTO is an option!



--

Garry



Free usenet access at http://www.eternal-september.org

Classic VB Users Regroup!

comp.lang.basic.visual.misc

microsoft.public.vb.general.discussion


Thank you Gary and Isabelle for the responses.

I have some add-ins on my computer related to the Yardi Software Templates that I'm using. Didn't think of the add-in side in place of the Macro.

I currently have some macros on a separate file that I run for specific files, keeps those files macro free. As we continue to improve our daily reporting for the executives, your option sounds useful for other avenues as well.

Thanks again!!!!!
 
G

GS

Thank you Gary and Isabelle for the responses.

I have some add-ins on my computer related to the Yardi Software
Templates that I'm using. Didn't think of the add-in side in place of
the Macro.

I currently have some macros on a separate file that I run for
specific files, keeps those files macro free. As we continue to
improve our daily reporting for the executives, your option sounds
useful for other avenues as well.

Thanks again!!!!!

Sounds like time not wasted! Glad you can see light ahead. Happy to
help...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top