LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 222
Default Using a Macro from one workbook within another

If your workbooks have the same macros in them, wouldn't it be as well to
run the macro DoThis() from workbook1?

"Rob" wrote:

Hello.

Here's the scenario... I have one workbook open and I copy specific sheets
into a new woorkbook, now both have the same macros in them, what I want to
do is use woorkbook1 to switch control to workbook2 and run a macro that is
in workbook2.

For example: Workbook1 code...

Private Sub CommandButton1_Click()
'Select Tabs and Copy
Sheets(Array("Info", "Data")).Copy

'Save New Workbook
ActiveWorkbook.SaveAs Filename:="WorkBook2.xls", FileFormat:=xlNormal,
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
CreateBackup:=False

Windows("WorkBook2.xls").Activate

'Use Macro That's In WorkBook2
Call DoThis(WorkBook2.xls)

End Sub

Here's the Code in WorkBook2.xls:

Sub DoThis()
WorkBooks("WorkBook2.xls").Close
MsgBox("All Done Boss.")
End Sub


Any Ideas on this?

Thanks in Advance.
Rob

 
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
saving macro from workbook to Personal Macro Workbook KrispyData Excel Discussion (Misc queries) 1 March 25th 10 05:52 PM
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook Ruchir Excel Worksheet Functions 1 July 25th 08 07:29 AM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Excel Programming 9 July 25th 05 12:44 PM
Need a macro to copy a range in one workbook and paste into another workbook Paul Excel Programming 8 July 1st 04 07:42 AM
Excel Gurus = want a macro in 1 workbook to get info from another workbook = Read please harry Excel Programming 5 December 20th 03 03:26 AM


All times are GMT +1. The time now is 06:51 PM.

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

About Us

"It's about Microsoft Excel"