Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default VB. NET Code to Change Excel Worksheet Header/Footer.

I need the VB.NET code to change the header/footer of an Excel spread sheet,
ASAP.
I am doing it through a VB application. I can change the ranges/cell values
using code, but I do not know how to change things outside of the cell
ranges. I will try and post in an Excel group, but i do not need to change
it in a worksheet, I need to change it through a VB application. For
example, I am using this code to change values in certain cells:

'open excel document
Dim ThisApplication As Excel.Application
ThisApplication = New Excel.Application
' Start Excel and get Application object.
ThisApplication = CreateObject("Excel.Application")
ThisApplication.Visible = True
'connection for package
Dim Wb As Excel.Workbook =
ThisApplication.Workbooks.Open("C:\CDRLReview.xls" )
Dim CDRLWs As Excel.Worksheet = Wb.Worksheets(1)
Dim DIDWs As Excel.Worksheet = Wb.Worksheets(2)

DIDWs.Range("a2").Value = "There is no DID associated with this
CDRL."
DIDWs.Range("a2").Font.ColorIndex = 3
DIDWs.Range("a2").Font.Bold = True

This code works! Yet, I need to change the Worksheet's header in the same
fashion.

I need to know if i can do something like:

DIDWs.Header.Value = <~~ I don' t know what the correct code is, it's just
an example.

Thanks in Advance.
~Elena


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default VB. NET Code to Change Excel Worksheet Header/Footer.

Elena,

Try

DIDws.PageSetup.CenterHeader = "Your text"

You can use Left/Center/Right Header/Footer.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Elena" wrote in message
...
I need the VB.NET code to change the header/footer of an Excel
spread sheet,
ASAP.
I am doing it through a VB application. I can change the
ranges/cell values
using code, but I do not know how to change things outside of
the cell
ranges. I will try and post in an Excel group, but i do not
need to change
it in a worksheet, I need to change it through a VB
application. For
example, I am using this code to change values in certain
cells:

'open excel document
Dim ThisApplication As Excel.Application
ThisApplication = New Excel.Application
' Start Excel and get Application object.
ThisApplication = CreateObject("Excel.Application")
ThisApplication.Visible = True
'connection for package
Dim Wb As Excel.Workbook =
ThisApplication.Workbooks.Open("C:\CDRLReview.xls" )
Dim CDRLWs As Excel.Worksheet = Wb.Worksheets(1)
Dim DIDWs As Excel.Worksheet = Wb.Worksheets(2)

DIDWs.Range("a2").Value = "There is no DID
associated with this
CDRL."
DIDWs.Range("a2").Font.ColorIndex = 3
DIDWs.Range("a2").Font.Bold = True

This code works! Yet, I need to change the Worksheet's header
in the same
fashion.

I need to know if i can do something like:

DIDWs.Header.Value = <~~ I don' t know what the correct code
is, it's just
an example.

Thanks in Advance.
~Elena




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default VB. NET Code to Change Excel Worksheet Header/Footer.

Thank you!


"Chip Pearson" wrote:

Elena,

Try

DIDws.PageSetup.CenterHeader = "Your text"

You can use Left/Center/Right Header/Footer.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Elena" wrote in message
...
I need the VB.NET code to change the header/footer of an Excel
spread sheet,
ASAP.
I am doing it through a VB application. I can change the
ranges/cell values
using code, but I do not know how to change things outside of
the cell
ranges. I will try and post in an Excel group, but i do not
need to change
it in a worksheet, I need to change it through a VB
application. For
example, I am using this code to change values in certain
cells:

'open excel document
Dim ThisApplication As Excel.Application
ThisApplication = New Excel.Application
' Start Excel and get Application object.
ThisApplication = CreateObject("Excel.Application")
ThisApplication.Visible = True
'connection for package
Dim Wb As Excel.Workbook =
ThisApplication.Workbooks.Open("C:\CDRLReview.xls" )
Dim CDRLWs As Excel.Worksheet = Wb.Worksheets(1)
Dim DIDWs As Excel.Worksheet = Wb.Worksheets(2)

DIDWs.Range("a2").Value = "There is no DID
associated with this
CDRL."
DIDWs.Range("a2").Font.ColorIndex = 3
DIDWs.Range("a2").Font.Bold = True

This code works! Yet, I need to change the Worksheet's header
in the same
fashion.

I need to know if i can do something like:

DIDWs.Header.Value = <~~ I don' t know what the correct code
is, it's just
an example.

Thanks in Advance.
~Elena





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
don't want to have to change font in header and footer each time? rtur Excel Worksheet Functions 1 March 16th 10 09:23 PM
Change Header & Footer Info w/ Worksheet Option Buttons Ryan H Excel Discussion (Misc queries) 0 December 8th 09 03:09 PM
what code pulls in contents of a cell in an Excel header/footer? Ronnyk Excel Discussion (Misc queries) 3 September 13th 07 08:18 PM
I need to change the Excel Header and Footer margins to match the Training Goddess Excel Worksheet Functions 2 May 4th 07 09:21 PM
Share Excel worksheet custom header/footer throughout workbook. zilla1906 Excel Worksheet Functions 2 January 12th 05 11:53 AM


All times are GMT +1. The time now is 02:20 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"