The problem you have is that during the OnLoad event, the View object doesn't exist. You will need to do this during the OnSwitchView event. If you only want it to happen once, you will need to set a flag in your code to identify whether you've already done this (i.e. assuming there is more than one view to switch to).

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
I would like to hide a custom task pane that I have created, so i have added
the following code to the onload event
Dim oTaskPane As HTMLTaskPaneObject = thisXDocument.View.Window.TaskPanes(0)
oTaskPane.Visible = False
and get the following error
System.NullReferenceException
Object reference not set to an instance of an object.
any suggestions on how to hide the task pane, until i open it on a onchange
event.
Steve - 22 Mar 2005 02:37 GMT
Thanks, it works, but seems to me that it is a messy way of doing it.
> The problem you have is that during the OnLoad event, the View object doesn't exist. You will need to do this during the OnSwitchView event. If you only want it to happen once, you will need to set a flag in your code to identify whether you've already done this (i.e. assuming there is more than one view to switch to).
>
[quoted text clipped - 11 lines]
> any suggestions on how to hide the task pane, until i open it on a onchange
> event.
Greg Collins [InfoPath MVP] - 22 Mar 2005 03:19 GMT
You are right -- but there's no other way. The part I don't like is that you see the task pane flash as it displays and then disappears. Oh well!

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
Thanks, it works, but seems to me that it is a messy way of doing it.
"Greg Collins [InfoPath MVP]" wrote:
> The problem you have is that during the OnLoad event, the View object doesn't exist. You will need to do this during the OnSwitchView event. If you only want it to happen once, you will need to set a flag in your code to identify whether you've already done this (i.e. assuming there is more than one view to switch to).