Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default need macro to call a workbook w/o the actual name of the workbook

In pseudo code

If workbooks.count < 2 then Exit Sub
For each wb in workbooks
If wb.name < activeworkbook.name then
' do the stuff here, this is the one
End If
next

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"crimsonkng" wrote in message
...
I have two workbooks open. In my macro, I don't want to refer to them by
their names because, basically, I never know what the name of the files
will
be. In other words, if I'm in one workbook, I merely want my macro to go
to
"the other workbook." And, then, if I'm in THAT workbook, I want the
macro
to go to the OTHER workbook.

Below, are some lines from my macro. I'm in one workbook, I copy some
cells, then I open a new workbook (below, called Book6), paste the data
into
the new workbook. Then, I add some sheets to the new workbook and rename
'em. Then, I want to go back to the other workbook (called "Investment
Quotation Install.xls" below) and copy-and-paste some more stuff.

The problem is that I will never know the name of either workbook. So, I
don't want to refer to them as "Investment Quotation Install.xls" or as
"Book6." (That just happens to be their name in my example.) I just want
to
say "go to the other workbook."

I assume that there are keystrokes that will switch back-and-forth between
the two, open workbooks (like Alt-W, 2) but the SendKeys commmand never
works
(for me, anyway) in a macro.

Any ideas?


Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

Sheets("Sheet1").Select
Sheets.Add
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "Expenses"
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Installation"
Sheets("Installation").Select
Sheets.Add
Sheets("Sheet3").Select
Sheets("Sheet3").Name = "Hours"
Sheets("Installation").Select
Sheets("Installation").Move Befo=Sheets(1)

Windows("Investment Quotation Install.xls").Activate
Sheets("Expenses").Select
Range("A1:J4").Select
Selection.Copy
Windows("Book6").Activate
Sheets("Expenses").Select
ActiveSheet.Paste
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A5").Select

(Truth be told, what I'm actually trying to do is to create a new workbook
without any macros. So, I'm copying the data from the one workbook - the
one
with the macros - to a new workbook (that won't have any macros) that will
have the data (values) from the first workbook. But I think it's
impossible
- or very difficult - to delete all the macros from my original workbook.
I
have about 50 of 'em and there's just no easy way to do it via a macro.)

Whew. Thanks in advance.




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
Macro call, one workbook to another Neal Zimm Excel Programming 7 September 18th 06 01:18 AM
How to call macro from other workbook ppyxl[_10_] Excel Programming 8 July 12th 06 04:33 PM
Call Macro from another WorkBook? Steven M. Britton[_2_] Excel Programming 6 June 10th 05 04:33 PM
How can I call a macro in another workbook? ned Excel Programming 4 May 31st 04 09:50 PM
Call a macro in other workbook Davwe[_4_] Excel Programming 2 December 17th 03 08:14 PM


All times are GMT +1. The time now is 08:58 AM.

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"