Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Activate WorkBook

I'm betting that FileNameNew includes a drive, a path, and the filename:

c:\my documents\excel\book999.xls

If that's the case, then
windows(filenamenew)
won't work.

It'll want a name of the window--and that name won't include the drive or path.

I'd use:

Dim FileNameNew as String
dim wkbk as workbook
filenamenew = "c:\my documents\excel\book999.xls"
set wkbk = Workbooks.Open(filename:=FileNameNew)
wkbk.activate

I'd go through the workbook collection, too--not the windows collection. If
there are multiple windows into that workbook open (book999.xls:1 and
book999.xls:2 would be in the titlebar), then windows() could fail.

geebee wrote:

hi,

I am getting a "runtime error 9: subscript out of range" when I try to open
a workbook:

Dim FileNameNew as String
Workbooks.Open FileNameNew
Windows(FileNameNew).Activate

The FileNameNew itself has an OnOpen event. Could this be causing the
problem?

How can I get around this? I just want to be able to Activate the
FileNameNew without going through this error message and possibly its OnOpen
event.

Thanks in advance,
geebee


--

Dave Peterson
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 hshayh0rn Excel Programming 4 February 13th 06 10:09 PM
Workbook.Activate / Window.Activate problem Tim[_44_] Excel Programming 3 February 3rd 06 11:38 PM
Activate workbook TimT Excel Programming 5 November 29th 05 08:41 PM
Activate Workbook Dolphinv4 Excel Discussion (Misc queries) 2 October 22nd 05 01:45 PM
Workbook.activate Jeff Excel Discussion (Misc queries) 1 December 13th 04 10:22 PM


All times are GMT +1. The time now is 05:12 PM.

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"