Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
don't want to have to change font in header and footer each time? | Excel Worksheet Functions | |||
Change Header & Footer Info w/ Worksheet Option Buttons | Excel Discussion (Misc queries) | |||
what code pulls in contents of a cell in an Excel header/footer? | Excel Discussion (Misc queries) | |||
I need to change the Excel Header and Footer margins to match the | Excel Worksheet Functions | |||
Share Excel worksheet custom header/footer throughout workbook. | Excel Worksheet Functions |