ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   the Parent property (https://www.excelbanter.com/excel-programming/366948-parent-property.html)

mrmack

the Parent property
 
I see a lot of the objects in the Excel Object Model have this 'Parent'
property.

I am only interested in retreiving the host Workbook for a worksheet, which
brought me to this article:
http://msdn2.microsoft.com/en-us/lib...et.parent.aspx

It worryingly states

"IF the current Worksheet has a parent, then name of the parent workbook is
displayed."

So, I guess my questions is

When would a worksheet not have a parent?

Charlie

the Parent property
 
Good question. Personally I thought that example was crap, but maybe I'm
missing something. I would think the author was trying to say "If Me.Parent
Is Nothing Then 'Me' is not a worksheet" I suspect all worksheets have a
parent.

P.S. if 'Me' is the workbook, not a sheet, then Me.Parent.Name returns
"Microsoft Excel"


"mrmack" wrote:

I see a lot of the objects in the Excel Object Model have this 'Parent'
property.

I am only interested in retreiving the host Workbook for a worksheet, which
brought me to this article:
http://msdn2.microsoft.com/en-us/lib...et.parent.aspx

It worryingly states

"IF the current Worksheet has a parent, then name of the parent workbook is
displayed."

So, I guess my questions is

When would a worksheet not have a parent?


NickHK

the Parent property
 
Under "normal" XL circumstances, .Parent returns the expected object.
However, (untested and only suspicion, test if you want) when you examine
this property in situations of:
- embedded in another OLE file
- shown in a webrowser
- shown in an OLE control
you may get different answers.

I can see that a WS.Parent may not be WB, but I fail to see how it could
Nothing.
How would you create/reference a WS that had no parent.

That code is saying that WS.Parent is either a WB or nothing.

NickHK

"mrmack" wrote in message
...
I see a lot of the objects in the Excel Object Model have this 'Parent'
property.

I am only interested in retreiving the host Workbook for a worksheet,

which
brought me to this article:

http://msdn2.microsoft.com/en-us/lib...et.parent.aspx

It worryingly states

"IF the current Worksheet has a parent, then name of the parent workbook

is
displayed."

So, I guess my questions is

When would a worksheet not have a parent?




NickHK

the Parent property
 
I should add:

That code is saying that WS.Parent is either a WB or nothing.

which seems misleading if the rest of my post correct.

NickHK

"NickHK" wrote in message
...
Under "normal" XL circumstances, .Parent returns the expected object.
However, (untested and only suspicion, test if you want) when you examine
this property in situations of:
- embedded in another OLE file
- shown in a webrowser
- shown in an OLE control
you may get different answers.

I can see that a WS.Parent may not be WB, but I fail to see how it could
Nothing.
How would you create/reference a WS that had no parent.

That code is saying that WS.Parent is either a WB or nothing.

NickHK

"mrmack" wrote in message
...
I see a lot of the objects in the Excel Object Model have this 'Parent'
property.

I am only interested in retreiving the host Workbook for a worksheet,

which
brought me to this article:


http://msdn2.microsoft.com/en-us/lib...et.parent.aspx

It worryingly states

"IF the current Worksheet has a parent, then name of the parent workbook

is
displayed."

So, I guess my questions is

When would a worksheet not have a parent?







All times are GMT +1. The time now is 03:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com