Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 334
Default how to set current workbook to the master after opening 2nd workbo

I need to know how to reset a primary workbook to active after executing a
procedure to open a 2nd workbook. I used the following code to open the 2nd
workbook:
Public Static Sub OpenFiles(BkNme)
Dim ThsWrkBk As Workbook
Dim WorkBk As Workbook
Dim WrkBk As String
Dim BKPath As String
Set ThsWrkBk = ActiveWorkbook
BKPath = "C:\Documents and Settings\Richard L. Harig\My
Documents\Excell\Financials\"
WrkBk = BKPath & BkNme
On Error Resume Next
Set WorkBk = Workbooks(BkNme)
If WorkBk Is Nothing Then
On Error Resume Next
Workbooks.Open Filename:=WrkBk, UpdateLinks:=3
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default how to set current workbook to the master after opening 2nd workbo

Just add

ThsWrkBk.Activate

at the end of the Sub.

Tim




"Rick" wrote in message
...
I need to know how to reset a primary workbook to active after executing a
procedure to open a 2nd workbook. I used the following code to open the
2nd
workbook:
Public Static Sub OpenFiles(BkNme)
Dim ThsWrkBk As Workbook
Dim WorkBk As Workbook
Dim WrkBk As String
Dim BKPath As String
Set ThsWrkBk = ActiveWorkbook
BKPath = "C:\Documents and Settings\Richard L. Harig\My
Documents\Excell\Financials\"
WrkBk = BKPath & BkNme
On Error Resume Next
Set WorkBk = Workbooks(BkNme)
If WorkBk Is Nothing Then
On Error Resume Next
Workbooks.Open Filename:=WrkBk, UpdateLinks:=3
End If
End Sub



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
Display Current Date & Time in a cell: Everytime I open the workbo sam Excel Worksheet Functions 4 September 3rd 09 11:30 PM
How do I update data in linked cells without opening source workbo TIII Excel Worksheet Functions 1 July 26th 06 04:21 PM
SELECTING CURRENT DATE BY OPENING WORKBOOK R VAN DEURSEN Excel Programming 1 March 3rd 05 12:06 PM
When opening an existing workbook, Excel opens but not the workbo. llhughes Excel Discussion (Misc queries) 1 February 12th 05 07:41 PM
opening a workbook in the current directory Richard[_16_] Excel Programming 2 August 30th 03 02:46 AM


All times are GMT +1. The time now is 06:12 AM.

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"