Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
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
Activate Workbook Dolphinv4 Excel Discussion (Misc queries) 2 October 22nd 05 01:45 PM
Activate a workbook from a selection GregR Excel Discussion (Misc queries) 1 April 7th 05 03:25 AM
Workbook.activate Jeff Excel Discussion (Misc queries) 1 December 13th 04 10:22 PM
Activate Workbook Molly Johnson Excel Programming 1 February 10th 04 05:09 PM
Activate Workbook Fred[_16_] Excel Programming 1 December 2nd 03 05:15 PM


All times are GMT +1. The time now is 01:17 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"