View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
noobi noobi is offline
external usenet poster
 
Posts: 3
Default how to copy/paste macro to a newly created file using vba

Working with personal.xls is fine, but in this case I need something
which help me to automate the process of copying files, which will be
later sended by email. I mean there is a datasheet with macros and so on
on which my friend works and there is a macro included in this file
which makes copy of the data and send it by email to some people from
other department in my company /different city and the network/. Using
option with personal.xls type I think there can be some problems,
because knowing theese people I can imagine to often thay will loose
this file. Able to automatically copy my function to newly created file
will be more stable /esp. for people knowing almost nothing about excel/.
That's why I look for any suggestion, clue or even full example of how
to do this. Unfortunatelly I've never had to do such things - working by
myself I can do this thx to personal.xls or manually.

But still thanks for an advice and I hope you can still sugest me
something more :-)

rgds,
Maleo


Gord Dibben wrote:
Perhaps better to store the macros/function in your Personal.xls workbook which
will make them available for all open workbooks.

If you don't have a Personal.xls yet, with your workbook open, go to
ToolsMacroRecord a new MacroStore Macro in;Personal Macro Workbook.

Record yourself copying and pasting something then Stop Recording.

Alt + F11 to open the VBEditor.

You will see the two workbooks. Yours and Personal.xls

Copy the macros/functions from your workbook into the module1 in Personal.xls.

Note: any hard-coded sheets or books should be changed to ActiveSheet or
ActiveWorkbook

Delete the bogus copy/paste macro if you choose.

Personal.xls can be hidden and saved so's it always opens in the background with
macros available.

Clear the maros/functions from the original workbook if the above works OK.


Gord Dibben MS Excel MVP

On Tue, 01 Apr 2008 01:19:03 +0200, noobi wrote:

Hello,

I have a workbook with numbers of macros - one of it translate data
numbers into text "in words". I've created a function which after
fullfilling datasheet, is copying it into a new file. And now I have a
problem, because in a new workbook there is no macro and of course there
isn't my function, so the datasheet doesn't works good.
I don't want to copy this function manually - I'd like to make it more
automatic /during copying data into a new workbook/. Unfortunatelly I
don't know how to do it.
If somebody knows how to do it, Please - show me an example.

thx,
Maleo