Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Header Headache!

Frank did a great job helping with with the code to link a cell into th
header

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wkSht As Worksheet
For Each wkSht In Me.Worksheets
With wkSht.PageSetup
.CenterFooter = wkSht.Range("A1").value
End With
Next wkSht
End Sub

I'm right clicking on the sheet tab and pasting this code under "vie
code". When I go back to the excel sheet I put the text I want in Cel
A1. Then go to print preview and nothing, I printed and nothing. So
Thought there might be something wrong. So I searched the forums fo
the same topic and read 5 post where this same code worked for them.

Is there a step I'm missing, I'm going crazy!
I'm using Excel 2002

Thanks in advance for the asprin!

Oh and I tried opening a plain NEW excel sheet putting "JohnDoe" i
cell A1 then pasting this code in the editor, still nothing

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Header Headache!

Hi
this code goes in the workbook module. Try the following
- open your workbook
- open the VBA editor (ALT+F11)
- doubleclick on 'ThisWorkbook' in the left explorer window of the VBA
editor
- paste the code
- close the VBA editor and save the workbook

No goto print preview and have a look if it works
Note: This will link cell A1 for all sheets of your workbook!

--
Regards
Frank Kabel
Frankfurt, Germany
"CWit " schrieb im Newsbeitrag
...
Frank did a great job helping with with the code to link a cell into

the
header

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wkSht As Worksheet
For Each wkSht In Me.Worksheets
With wkSht.PageSetup
CenterFooter = wkSht.Range("A1").value
End With
Next wkSht
End Sub

I'm right clicking on the sheet tab and pasting this code under "view
code". When I go back to the excel sheet I put the text I want in

Cell
A1. Then go to print preview and nothing, I printed and nothing. So I
Thought there might be something wrong. So I searched the forums for
the same topic and read 5 post where this same code worked for them.

Is there a step I'm missing, I'm going crazy!
I'm using Excel 2002

Thanks in advance for the asprin!

Oh and I tried opening a plain NEW excel sheet putting "JohnDoe" in
cell A1 then pasting this code in the editor, still nothing.


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Header Headache!

Aspirin:
That code belongs not in a sheet module, but in the ThisWorkbook module.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"CWit " wrote in message
...
Frank did a great job helping with with the code to link a cell into the
header

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wkSht As Worksheet
For Each wkSht In Me.Worksheets
With wkSht.PageSetup
CenterFooter = wkSht.Range("A1").value
End With
Next wkSht
End Sub

I'm right clicking on the sheet tab and pasting this code under "view
code". When I go back to the excel sheet I put the text I want in Cell
A1. Then go to print preview and nothing, I printed and nothing. So I
Thought there might be something wrong. So I searched the forums for
the same topic and read 5 post where this same code worked for them.

Is there a step I'm missing, I'm going crazy!
I'm using Excel 2002

Thanks in advance for the asprin!

Oh and I tried opening a plain NEW excel sheet putting "JohnDoe" in
cell A1 then pasting this code in the editor, still nothing.


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Header Headache!

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wkSht As Worksheet
For Each wkSht In Me.Worksheets
With wkSht.PageSetup
.CenterFooter = wkSht.Range("A1").value
End With
Next wkSht
End Sub

You should have a period before CenterFooter

--
Regards,
Tom Ogilvy

"CWit " wrote in message
...
Frank did a great job helping with with the code to link a cell into the
header

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wkSht As Worksheet
For Each wkSht In Me.Worksheets
With wkSht.PageSetup
CenterFooter = wkSht.Range("A1").value
End With
Next wkSht
End Sub

I'm right clicking on the sheet tab and pasting this code under "view
code". When I go back to the excel sheet I put the text I want in Cell
A1. Then go to print preview and nothing, I printed and nothing. So I
Thought there might be something wrong. So I searched the forums for
the same topic and read 5 post where this same code worked for them.

Is there a step I'm missing, I'm going crazy!
I'm using Excel 2002

Thanks in advance for the asprin!

Oh and I tried opening a plain NEW excel sheet putting "JohnDoe" in
cell A1 then pasting this code in the editor, still nothing.


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Header Headache!

"Tom Ogilvy" wrote in message
...

You should have a period before CenterFooter


Oops. You have the eyes of an eagle, Tom.

Best wishes Harald
Followup to newsgroup only please.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Header Headache!

Well, I open a brand new excel sheet and hit alt-F11 and it open the VB
editor. I see File Edit View etc. And the rest is blank. Now if I got
"View" - then "Code" It opens a white box on the left there is a dro
down menu with 2 selections "General" and "Worksheet". No where on th
VBA editor do I see ThisWorkBook. I even searched for ThisWorkBook i
help and all it said was ThisWorkBook properties but did not show ho
to get there.

Srry, I can't find it

--
Message posted from http://www.ExcelForum.com

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Header Headache!

Hi
in the left window should be a eplorer tree view with your workbook
file as one project. Expand this project and the first entry below
should be 'ThisWorkbook'

another option:
- open your workbook
- right-click on the Excel symbol directly left to the menu 'File'
- choose 'Code'
- now you're in the workbook module

--
Regards
Frank Kabel
Frankfurt, Germany
"CWit " schrieb im Newsbeitrag
...
Well, I open a brand new excel sheet and hit alt-F11 and it open the

VBA
editor. I see File Edit View etc. And the rest is blank. Now if I

goto
"View" - then "Code" It opens a white box on the left there is a drop
down menu with 2 selections "General" and "Worksheet". No where on

the
VBA editor do I see ThisWorkBook. I even searched for ThisWorkBook in
help and all it said was ThisWorkBook properties but did not show how
to get there.

Srry, I can't find it.


---
Message posted from http://www.ExcelForum.com/


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Header Headache!

if you look at the code i posted it has period before CenterFooter...

I just can't seem to find the "Thisworkbook"

I'm such a N00b

--
Message posted from http://www.ExcelForum.com

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Header Headache!

OMG THANK YOU FRANK!!! Huge Smile on my FACE :) :)

I right clicked the symbol and viewed code and it work!! Thanks Fran
and everyone else for making this Simple but Frustrating Headache g
away..

--
Message posted from http://www.ExcelForum.com

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Header Headache!

If you look, you will see you don't. I don't doubt that you do actually
have it, but periods on the left margin can get removed in postings.

in the VBE, go to the projecte explorer Ctrl+R if it isn't visible. Under
your workbook name, you should find an entry ThisWorkbook. Double click on
that or right click on it and select view code to get to the ThisWorkbook
module

In the left dropdown at the top, select Workbook and in the Right select
Open.

This shoul put in the proper declaration for the workbook_Open event. This
is the way you should enter event macros. No you can put your code in this
procedure.

--
Regards,
Tom Ogilvy


"CWit " wrote in message
...
if you look at the code i posted it has period before CenterFooter...

I just can't seem to find the "Thisworkbook"

I'm such a N00b!


---
Message posted from http://www.ExcelForum.com/





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Header Headache!

:-)
finally

--
Regards
Frank Kabel
Frankfurt, Germany
"CWit " schrieb im Newsbeitrag
...
OMG THANK YOU FRANK!!! Huge Smile on my FACE :) :)

I right clicked the symbol and viewed code and it work!! Thanks Frank
and everyone else for making this Simple but Frustrating Headache go
away...


---
Message posted from http://www.ExcelForum.com/


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frequency Headache Rothman Excel Worksheet Functions 6 March 9th 06 09:25 PM
headache! :) unique_id's cjjoo Excel Worksheet Functions 7 October 21st 05 03:24 AM
Vlookup Headache Stressed Out!! Excel Worksheet Functions 1 September 14th 05 06:03 AM
AND Headache (with dates)! Alan L. Wagoner Excel Programming 2 February 19th 04 03:41 PM
Look up Headache Chris Excel Programming 3 November 26th 03 02:55 PM


All times are GMT +1. The time now is 10:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"