PC Review


Reply
Thread Tools Rate Thread

ActiveSheet not in ActiveWorkbook?

 
 
=?Utf-8?B?SU5UUDU2?=
Guest
Posts: n/a
 
      31st Oct 2007
c:\SomeTextFile.txt is a text file created in NotePad that simply contains

A B C D E
F G H I J

Go into VBA and run this code:

Public Sub OpenTextFile()
Dim wbActive As Workbook, wsActive As Worksheet
Dim wbActiveSheetParent As Workbook, wsRangeParent As Worksheet
Const cstrFileName As String = "c:\SomeTextFile.txt"
If Len(Dir(cstrFileName)) > 0 Then
Workbooks.OpenText Filename:=cstrFileName
Set wbActive = ActiveWorkbook
Set wsActive = ActiveSheet
Set wbActiveSheetParent = wsActive.Parent
Set wsRangeParent = ActiveCell.Parent
MsgBox "wbActive: " + wbActive.Name + vbCrLf + "wsActive: " +
wsActive.Name + vbCrLf + _
"wbActiveSheetParent: " + wbActiveSheetParent.Name + vbCrLf +
"wsRangeParent: " + wsRangeParent.Name
ActiveWorkbook.Close
End If
End Sub


When the message box appears, I see a spreadsheet with the file I just
opened. SomeTextFile.txt is in the title bar, and the Worksheet I see is
named SomeTextFile.

My message box contains:

wbActive: SomeTextFile.txt
wsActive: Sheet1
wbActiveSheetParent: Book1
wsRangeParent: SomeTextFile

How is this possible? Is this a known bug? Has anyone else run across this?

Bob

 
Reply With Quote
 
 
 
 
Bill Renaud
Guest
Posts: n/a
 
      1st Nov 2007
When I run your code in Excel 2000, my message box contains:

wbActive: SomeTextFile.txt
wsActive: SomeTextFile
wbActiveSheetParent: SomeTextFile.txt
wsRangeParent: SomeTextFile

Is this what you were expecting?
--
Regards,
Bill Renaud



 
Reply With Quote
 
=?Utf-8?B?SU5UUDU2?=
Guest
Posts: n/a
 
      1st Nov 2007
Bill,

Yes, that IS what I was expecting .... but what I get is

wbActive: SomeTextFile.txt
wsActive: Sheet1
wbActiveSheetParent: Book1
wsRangeParent: SomeTextFile

I'm running Excel 2003, what version are you running?

Bob


"Bill Renaud" wrote:

> When I run your code in Excel 2000, my message box contains:
>
> wbActive: SomeTextFile.txt
> wsActive: SomeTextFile
> wbActiveSheetParent: SomeTextFile.txt
> wsRangeParent: SomeTextFile
>
> Is this what you were expecting?
> --
> Regards,
> Bill Renaud
>
>
>
>

 
Reply With Quote
 
Bill Renaud
Guest
Posts: n/a
 
      1st Nov 2007
<<what version are you running?>>

Excel 2000, as I mentioned in the first line of my post.
Actually, to be more correct: Excel 2000 SP-3 (Service Pack 3; which I
believe is the last one).

Do you have all of the service releases (or patches) applied?
--
Regards,
Bill Renaud



 
Reply With Quote
 
=?Utf-8?B?SU5UUDU2?=
Guest
Posts: n/a
 
      5th Nov 2007
Hi Bill,

Yes, I noticed that after I posted my reply. Sorry about that.

I am using Excel 2003, version (11.8146.8132) SP2 on Win2K

Actually, now that I mentioned the OS, I tried the same test with the same
version of Excel on a WinXp machine, and it works as expected. I guess I
should have tried that first.

So, maybe it's OS related.

Bob

"Bill Renaud" wrote:

> <<what version are you running?>>
>
> Excel 2000, as I mentioned in the first line of my post.
> Actually, to be more correct: Excel 2000 SP-3 (Service Pack 3; which I
> believe is the last one).
>
> Do you have all of the service releases (or patches) applied?
> --
> Regards,
> Bill Renaud
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveWorkBook versus ActiveSheet Boiler-Todd Microsoft Excel Misc 5 21st Sep 2009 10:42 PM
Use a password in VBA ActiveSheet.protect & ActiveSheet.unprotect? Jim K. Microsoft Excel Programming 2 2nd Jun 2008 08:09 PM
Copying new activesheet after other activesheet is hidden? Simon Lloyd Microsoft Excel Programming 1 20th Jun 2006 10:02 AM
an 400 error about ActiveWorkbook.ActiveSheet.Cells(row, col) Leon Microsoft VB .NET 0 1st Aug 2005 11:00 PM
ActiveWorkBook Pete Microsoft Excel Misc 3 9th May 2005 04:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:58 PM.