Trying to remove IE Header & Footer but i'm getting a NullReferenceException.. help?
Hey Guys,
I am trying to get rid of the IE added header and footer such as Page Title, Page 1 of 1, Url, Etc..
I am using the following code. My goal is when a user click on the PRINT button within my application, I would call SetIEON, print the page and SetIEOff.
However, when my code gets to SetIEOn at
Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable)
oKey.SetValue(strName, oValue)
it crashes with a NullReferenceException. Any idea why ? I'm using VS 2008 .NET 2.0
See code below.
'Removing the header and footer in the Windows Registry
Public Sub SetIEOn()
Dim strKey As String = "Software\Microsoft\Internet Explorer\PageSetup"
Dim bolWritable As Boolean = True
Dim strName As String = "footer"
Dim oValue As Object = ""
Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable)
oKey.SetValue(strName, oValue)
strName = "header"
oValue = ""
oKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable)
oKey.SetValue(strName, oValue)
oKey.Close()
End Sub
'Adding the header and footer in the Windows Registry
Public Sub SetIEOff()
Dim strKey As String = "Software\Microsoft\Internet Explorer\PageSetup"
Dim bolWritable As Boolean = True
Dim strName As String = "footer"
Dim oValue As Object = "&u&b&d"
Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable)
oKey.SetValue(strName, oValue)
strName = "header"
oValue = "&w&bPage &p of &P"
oKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable)
oKey.SetValue(strName, oValue)
oKey.Close()
End Sub
Thanks so much!!!!
Peter
Hey Guys,
I am trying to get rid of the IE added header and footer such as Page Title, Page 1 of 1, Url, Etc..
I am using the following code. My goal is when a user click on the PRINT button within my application, I would call SetIEON, print the page and SetIEOff.
However, when my code gets to SetIEOn at
Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable)
oKey.SetValue(strName, oValue)
it crashes with a NullReferenceException. Any idea why ? I'm using VS 2008 .NET 2.0
See code below.
'Removing the header and footer in the Windows Registry
Public Sub SetIEOn()
Dim strKey As String = "Software\Microsoft\Internet Explorer\PageSetup"
Dim bolWritable As Boolean = True
Dim strName As String = "footer"
Dim oValue As Object = ""
Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable)
oKey.SetValue(strName, oValue)
strName = "header"
oValue = ""
oKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable)
oKey.SetValue(strName, oValue)
oKey.Close()
End Sub
'Adding the header and footer in the Windows Registry
Public Sub SetIEOff()
Dim strKey As String = "Software\Microsoft\Internet Explorer\PageSetup"
Dim bolWritable As Boolean = True
Dim strName As String = "footer"
Dim oValue As Object = "&u&b&d"
Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable)
oKey.SetValue(strName, oValue)
strName = "header"
oValue = "&w&bPage &p of &P"
oKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable)
oKey.SetValue(strName, oValue)
oKey.Close()
End Sub
Thanks so much!!!!
Peter