Armin,
Let me try and be more clear:
I need the VB.NET code to change the header/footer of an Excel spread sheet.
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.Applicati on
ThisApplication = New Excel.Applicati on
' Start Excel and get Application object.
ThisApplication = CreateObject("E xcel.Applicatio n")
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.ColorIn dex = 3
DIDWs.Range("a2 ").Font.Bol d = 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.Va lue = <~~ I don' t know what the correct code is, it's just
an example.
~Elena
"Armin Zingler" wrote:
"Elena" <El***@discussi ons.microsoft.c om> schrieb I'm not sure what you mean. I looked at the article you pointed me
to and I only see ranges or cells. This is the header/footer
outside of the cells and on the sheet itself. I'm sorry if I wasn't
clear before.
I already have the library referenced. You need it to be able to
export anything to Excel.
I didn't know how you exported it to an Excel file and that you already have
a reference to Excel and know how to use it. Therefore the link. Though,
have a look at the Excel object model in the Excel documentation. See also
the appropriate microsoft.publi c.excel.* group.
Armin
"Armin Zingler" wrote:
"Elena" <El***@discussi ons.microsoft.c om> schrieb
> I'm trying to export data to an Excel worksheet. I can export the
> data in the cell values perfectly.
>
> I need the code to change a header and footer for the worksheet, not
> for the columns.
>
> Is this possible? If so, I really need the code immediately.
Have a look at the Excel object model in the Excel documentation. You can
use Excel via COM interop by setting a reference to the "Microsoft Excel
x.y
object library" on the COM folder on the "add references" dialog.
See also:
http://support.microsoft.com/kb/301982/en-us