Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Open workbook without activating it

First: I am not much of a VBA coder. Usually, I record a macro and
edit it slightly.

I would like to create a macro that opens a specific workbook without
making it the active workbook. I'd like it to be transparent to the
user. Since this is going in a template, the user may not have saved
his current workbook, so I can't just switch back to a specific
workbookname.

Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Open workbook without activating it

Sub OpenNoActivate()
Dim wBk As Workbook

Set wBk = ActiveWorkbook
Application.ScreenUpdating = False
Workbooks.Open FileName:="YourFileName"
wBk.Activate
Application.ScreenUpdating = True

End Sub

Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

First: I am not much of a VBA coder. Usually, I record a macro and
edit it slightly.

I would like to create a macro that opens a specific workbook without
making it the active workbook. I'd like it to be transparent to the
user. Since this is going in a template, the user may not have saved
his current workbook, so I can't just switch back to a specific
workbookname.

Any ideas?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Open workbook without activating it

Dim wkbk as Workbook
set wkbk = ActiveWorkbook
Application.ScreenUpdating = False
workbooks.Open "C:\My documents\Mybook.xls"
wkbk.Activate
Application.ScreenUpdating = True

--
Regards,
Tom Ogilvy

"Kelley" wrote in message
om...
First: I am not much of a VBA coder. Usually, I record a macro and
edit it slightly.

I would like to create a macro that opens a specific workbook without
making it the active workbook. I'd like it to be transparent to the
user. Since this is going in a template, the user may not have saved
his current workbook, so I can't just switch back to a specific
workbookname.

Any ideas?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Open workbook without activating it

Kelley,

Dim wkbk as String

wkbk = Activeworkbook.name

ScreenUpdating = False ' prevents screen from showing changes
Workbooks.Open FileName:="MyDrive\MyFolder\MyBook.xls"
Windows(wkbk).Activate
ScreenUpdating = True

You might want to record a macro to get the Workbook.Open part
of the code.

This should work even if the wkbk hasn't been saved.
(code not tested)

--
sb
"Kelley" wrote in message
om...
First: I am not much of a VBA coder. Usually, I record a macro and
edit it slightly.

I would like to create a macro that opens a specific workbook without
making it the active workbook. I'd like it to be transparent to the
user. Since this is going in a template, the user may not have saved
his current workbook, so I can't just switch back to a specific
workbookname.

Any ideas?



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
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
how do i open a data workbook when i open a timesheet workbook [email protected] uk Excel Discussion (Misc queries) 2 January 4th 09 04:50 PM
Activating workbook with variable Name Mark Klaus Excel Programming 2 October 24th 03 10:41 PM
Activating a workbook help bmwmcrider Excel Programming 1 October 21st 03 01:48 PM
Activating a worksheet with a user form open on the screen KimberlyC Excel Programming 4 August 29th 03 08:44 PM


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