By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,701 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,701 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Mar 13 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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
Mar 13 '06 #2

P: n/a
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.

"Cor Ligthert [MVP]" wrote:
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

Mar 13 '06 #3

P: n/a
"Elena" <El***@discussions.microsoft.com> schrieb
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

Mar 13 '06 #4

P: n/a
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
Mar 13 '06 #5

P: n/a
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.
"Cor Ligthert [MVP]" wrote:
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

Mar 13 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.