Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default how to copy/paste macro to a newly created file using vba

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default how to copy/paste macro to a newly created file using vba

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Refresh data from original worksheet to newly created copy wolverine Excel Discussion (Misc queries) 0 April 11th 10 04:10 PM
how to paste macro to a newly created file using vba noobi Excel Programming 1 April 1st 08 01:33 AM
Trouble with copy to newly created sheet brownti via OfficeKB.com Excel Programming 5 May 3rd 07 04:47 PM
cannot copy newly created files to backup, all existing ok NBaum Excel Discussion (Misc queries) 3 July 25th 06 07:29 PM
in VBA Sheets("mysheet").Copy Befo=Sheets(1) how do i get a reference to the newly created copy of this sheet? Daniel Excel Worksheet Functions 1 July 6th 05 09:57 PM


All times are GMT +1. The time now is 09:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"