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

Export Data to Excel

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

Thank you,
Elena
Mar 13 '06 #1
Share this Question
Share on Google+
6 Replies


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

Armin

Mar 13 '06 #2

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

"Armin Zingler" wrote:
"Elena" <El***@discussions.microsoft.com> 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

Armin

Mar 13 '06 #3

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

Armin

"Armin Zingler" wrote:
"Elena" <El***@discussions.microsoft.com> 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


Mar 13 '06 #4

P: n/a
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.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.
~Elena
"Armin Zingler" wrote:
"Elena" <El***@discussions.microsoft.com> 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.public.excel.* group.

Armin

"Armin Zingler" wrote:
"Elena" <El***@discussions.microsoft.com> 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


Mar 13 '06 #5

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

I do understand your concerns. I don't have an answer because this is a
question related to the Excel automation object model (that I don't know
that good), not a question about VB.Net. You obviously don't have a
problem in handling VB.Net but handling the Excel object model. In other
words, if you did it in C#, you would have the same question.
Armin

Mar 13 '06 #6

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

Start Excel, start recordin a macro, change the header, stop recording,
have a look at the generated macro source code. You can apply the same cod
in VB.Net then.
Armin

Mar 13 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.