ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Paste text into a header (https://www.excelbanter.com/excel-programming/334740-paste-text-into-header.html)

Danny Springer

Paste text into a header
 
I am trying to paste text into a header via code. I can't get it
working. Anyone?

Regards,
Danny

STEVE BELL

Paste text into a header
 
How do you get the text?
Are you talking of a header on the worksheet or
about a header in the print set-up?

you can use
Range("A1")=Range(D25)
or
Range("A1")=InputBox ("Enter a Header")
or
Range("A1")="My Header"

--
steveB

Remove "AYN" from email to respond
"Danny Springer" wrote in message
...
I am trying to paste text into a header via code. I can't get it working.
Anyone?

Regards,
Danny




Danny Springer

Paste text into a header
 
STEVE BELL wrote:

How do you get the text?
Are you talking of a header on the worksheet or
about a header in the print set-up?

I am talking about a header in the print set-up. If I record a macro and
paste my text, I will find the text in my macro, not the command "paste".

Regards,
Danny

STEVE BELL

Paste text into a header
 
Below is code I recorder, and below it is after editing it...
Replace the text with a cell reference, a text reference, a result
from an InputBox or form, or a variable.
==========================
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = "Left Header"
.CenterHeader = "Center Header"
.RightHeader = "Right Header"
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
End With
================================
With ActiveSheet.PageSetup
.LeftHeader = "Left Header"
.CenterHeader = "Center Header"
.RightHeader = "Right Header"
End With

========================================

--
steveB

Remove "AYN" from email to respond
"Danny Springer" wrote in message
...
STEVE BELL wrote:

How do you get the text?
Are you talking of a header on the worksheet or
about a header in the print set-up?

I am talking about a header in the print set-up. If I record a macro and
paste my text, I will find the text in my macro, not the command "paste".

Regards,
Danny




Danny Springer

Paste text into a header
 
STEVE BELL wrote:
Below is code I recorder, and below it is after editing it...

Ok, that is exactly what I already did, but I need to paste text from
the clipboard, not a fixed text. Any idea?

Thanks,
Danny

Replace the text with a cell reference, a text reference, a result
from an InputBox or form, or a variable.
==========================
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = "Left Header"
.CenterHeader = "Center Header"
.RightHeader = "Right Header"
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
End With
================================
With ActiveSheet.PageSetup
.LeftHeader = "Left Header"
.CenterHeader = "Center Header"
.RightHeader = "Right Header"
End With

========================================


STEVE BELL

Paste text into a header
 
The text on the clipboard is coming from a copied source.

you could just set a string variable = to the source.
(and this avoids selecting, copying, pasting)

that's what I alluded to when I said:
Replace the text with a cell reference, a text reference, a result
from an InputBox or form, or a variable.


Or have I gotton confused?


Dim str As Text

str = Range("A1")
With ActiveSheet.PageSetup
..LeftHeader = str
End With
--
steveB

Remove "AYN" from email to respond
"Danny Springer" wrote in message
...
STEVE BELL wrote:
Below is code I recorder, and below it is after editing it...

Ok, that is exactly what I already did, but I need to paste text from the
clipboard, not a fixed text. Any idea?

Thanks,
Danny

Replace the text with a cell reference, a text reference, a result
from an InputBox or form, or a variable.
==========================
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = "Left Header"
.CenterHeader = "Center Header"
.RightHeader = "Right Header"
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
End With
================================
With ActiveSheet.PageSetup
.LeftHeader = "Left Header"
.CenterHeader = "Center Header"
.RightHeader = "Right Header"
End With

========================================




Danny Springer

Paste text into a header
 
STEVE BELL wrote:
The text on the clipboard is coming from a copied source.

Yes, but it's coming from another program.

you could just set a string variable = to the source.
(and this avoids selecting, copying, pasting)

that's what I alluded to when I said:

Replace the text with a cell reference, a text reference, a result
from an InputBox or form, or a variable.



Or have I gotton confused?

No, you were clear, but I solved it, I first paste the text to a cell
and read it in a variable exactly as you told me. I was only very
surprised that I could not use the Paste command as I am used for a long
time with Word.

But thank you for sending me to this direction.

Danny


All times are GMT +1. The time now is 01:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com