Urgent: VB.NET Code to Change Excel Worksheet Header/Footer

G

Guest

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
 
C

Cor Ligthert [MVP]

Elena,

I thought that Armin had already given you a good answer. It has no sense of
spamming this newsgroup with consequent the same new messages. If somebody
sees that he can help you better than Armin did, than he/she will do that.

I assume that you did not know this, but please don't do it next time.

Thanx in advance.

Cor
 
G

Guest

Cor,

Armin did not give me a good answer. A good answer would have been:

ws.pagesetup.header = "your text"

by the way, which works perfectly.

I am not spaming the group. I reposted it because I trying to be clearer.
From my discussion with Armin, it seemed to me that my first submission was
unclear.

Maybe next time you should ask why someone reposted something instead of
assuming you were correct.

Thanks.
 
A

Armin Zingler

Elena said:
Cor,

Armin did not give me a good answer. A good answer would have been:

ws.pagesetup.header = "your text"

by the way, which works perfectly.


Your code gave the impression that you know how to set a property.



Armin
 
C

Cor Ligthert [MVP]

Elena,

If your repost had been in a day, than I could have understand it.

Now you did reply within 3 hours, this newsgroup is done by a lot of persons
from every where on the world and therefore almost 24 hours 7 days active.
However they are not all up at the time you want to get a question. It is
seen as polite if you will be so nice to accept that some persons need to
sleep sometimes and therefore wait something longer for an answer in a
newsgroup.

Cor
 
G

Guest

Cor,

I do not wish to argue with you, but you are obviousloy not reading my
replies. My repost was not due to speed, it was to be more clear. I wasn't
reposting to get an answer quickly, I reposted to get the answer I needed.

Armin,

I did not know the property I needed to set. That was my question. It has
been answered and the code works properly.

Thank you for your attempt to help.

Have a good day,
Elena.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top