Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Activate Other Workbook
Hi,
How do you activate another workbook if you do not know the name of it I know this sounds silly but i am being sent a workbook each week an am unsure if the name is going to change. Any help would be great. Also can you set a macro to copy itself from one workbook to another -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Activate Other Workbook
"Sent a workbook" - does that mean it's e-mailed to you? Do you want to
process the e-mail for the attachment and deal with it there? Otherwise, simply save the attachment with a consistent name. -- Rob van Gelder - http://www.vangelder.co.nz/excel "pauluk " wrote in message ... Hi, How do you activate another workbook if you do not know the name of it. I know this sounds silly but i am being sent a workbook each week and am unsure if the name is going to change. Any help would be great. Also can you set a macro to copy itself from one workbook to another? --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Activate Other Workbook
If you use code to access it when opened, you get a handle to it.
Set newWB = ActiveWorkbook then you can refer to myWB thereafter, active or not. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "pauluk " wrote in message ... Hi, How do you activate another workbook if you do not know the name of it. I know this sounds silly but i am being sent a workbook each week and am unsure if the name is going to change. Any help would be great. Also can you set a macro to copy itself from one workbook to another? --- Message posted from http://www.ExcelForum.com/ |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Activate Other Workbook
Bob this is what it will be
Theuser will be sent the file via e-mail they then open this file an also anothere file called data split I need the data split file to recongize the sent file. It will b called something different each time it is sent because will hav differnet info but this will be held the same. All i need to know is when the sent file is open how do i get my cod from the split data to reconignze the open file if i have not specifie a name -- Message posted from http://www.ExcelForum.com |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Activate Other Workbook
Paul,
Does the user know the difference between the two files. What I am thinking is that if you can get them tom open data first, that could have code to trap any other opens and ask the user if this is the one? -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "pauluk " wrote in message ... Bob this is what it will be Theuser will be sent the file via e-mail they then open this file and also anothere file called data split I need the data split file to recongize the sent file. It will be called something different each time it is sent because will have differnet info but this will be held the same. All i need to know is when the sent file is open how do i get my code from the split data to reconignze the open file if i have not specified a name. --- Message posted from http://www.ExcelForum.com/ |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Activate Other Workbook
The user will know the differnece.
I was thinking of placeing an input box at the start for the user t input the file name. But then it really does depend on the user placin the correct name otherwise the coding will not work -- Message posted from http://www.ExcelForum.com |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Activate Other Workbook
No we can do better than that.
What we do is add application events to trap every workbook being opened. On open, we ask if this is it, if so we get workbook automatically. This workbook object will be stored in thisWb, so just use thisWb when referencing the data thereafter. Firstly, all of this code goes in the designated workbook. '======================================== In a standard code module, declare a public variable of thisWB Public thisWB as Workbook '======================================== Insert a class module, rename it to 'clsAppEvents', with this code Option Explicit Public WithEvents App As Application Private Sub App_WorkbookOpen(ByVal Wb As Workbook) Dim ans ans = InputBox("Is the file?", vbYesNo) If ans = vbYes Then thisWB = ActiveWorkbook End If End Sub '======================================== In ThisWorkbook code module, add this event code Dim AppClass As New clsAppEvents Private Sub Workbook_Open() Set AppClass.App = Application End Sub -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "pauluk " wrote in message ... The user will know the differnece. I was thinking of placeing an input box at the start for the user to input the file name. But then it really does depend on the user placing the correct name otherwise the coding will not work. --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Activate Workbook | Excel Discussion (Misc queries) | |||
Activate a workbook from a selection | Excel Discussion (Misc queries) | |||
Workbook.activate | Excel Discussion (Misc queries) | |||
Activate Workbook | Excel Programming | |||
Activate Workbook | Excel Programming |