Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Programming header/footer strings with line feed

I am using Windows XP with Office 2003.

I have a VBA program in which I can enter a header or footer string in a
sheet and the program enters this string for me into the header or footer of
hundreds of files that are formatted automatically. For example a set up
string might look like:

&"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:

The above would be "Arial", bold, 10-points, underlined. This works great.

The only thing is, I need to be able to insert a return or a line feed at
the beginning and/or end of the string and I can't seem to get it to work.
For example, I tried variations of the following without success:

&Chr(10) &"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:
&"Chr(13)" &"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:

Could someone PLEASE help me out on this and post back a correction to make
it work?

Thanks so much in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Programming header/footer strings with line feed

CHR(10) works fine

Just tried this fine

With ActiveSheet.PageSetup
.LeftHeader = "&D" & Chr(10) & "&T"
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"XP" wrote in message
...
I am using Windows XP with Office 2003.

I have a VBA program in which I can enter a header or footer string in a
sheet and the program enters this string for me into the header or footer

of
hundreds of files that are formatted automatically. For example a set up
string might look like:

&"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:

The above would be "Arial", bold, 10-points, underlined. This works great.

The only thing is, I need to be able to insert a return or a line feed at
the beginning and/or end of the string and I can't seem to get it to work.
For example, I tried variations of the following without success:

&Chr(10) &"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:
&"Chr(13)" &"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:

Could someone PLEASE help me out on this and post back a correction to

make
it work?

Thanks so much in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Programming header/footer strings with line feed

Thanks Bob,

But if you put that string in a cell in the spreadsheet and then run the
following:

Dim sHeader as string
sHeader = Activecell.Formular1c1
Activesheet.PageSetup.CenterHeader = sHeader

It doesn't work. That is what I'm trying to do...

Thanks for your reply, please help if you can, any ideas?


"Bob Phillips" wrote:

CHR(10) works fine

Just tried this fine

With ActiveSheet.PageSetup
.LeftHeader = "&D" & Chr(10) & "&T"
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"XP" wrote in message
...
I am using Windows XP with Office 2003.

I have a VBA program in which I can enter a header or footer string in a
sheet and the program enters this string for me into the header or footer

of
hundreds of files that are formatted automatically. For example a set up
string might look like:

&"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:

The above would be "Arial", bold, 10-points, underlined. This works great.

The only thing is, I need to be able to insert a return or a line feed at
the beginning and/or end of the string and I can't seem to get it to work.
For example, I tried variations of the following without success:

&Chr(10) &"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:
&"Chr(13)" &"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:

Could someone PLEASE help me out on this and post back a correction to

make
it work?

Thanks so much in advance.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default Programming header/footer strings with line feed

I recorded this with the macro recorder, maybe it can give you a lead ...


.LeftFooter = "&""Arial,Bold""&11&UMy Idea" & Chr(10) & "Is This"


"XP" wrote in message
...
Thanks Bob,

But if you put that string in a cell in the spreadsheet and then run the
following:

Dim sHeader as string
sHeader = Activecell.Formular1c1
Activesheet.PageSetup.CenterHeader = sHeader

It doesn't work. That is what I'm trying to do...

Thanks for your reply, please help if you can, any ideas?


"Bob Phillips" wrote:

CHR(10) works fine

Just tried this fine

With ActiveSheet.PageSetup
.LeftHeader = "&D" & Chr(10) & "&T"
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"XP" wrote in message
...
I am using Windows XP with Office 2003.

I have a VBA program in which I can enter a header or footer string in
a
sheet and the program enters this string for me into the header or
footer

of
hundreds of files that are formatted automatically. For example a set
up
string might look like:

&"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:

The above would be "Arial", bold, 10-points, underlined. This works
great.

The only thing is, I need to be able to insert a return or a line feed
at
the beginning and/or end of the string and I can't seem to get it to
work.
For example, I tried variations of the following without success:

&Chr(10) &"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:
&"Chr(13)" &"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:

Could someone PLEASE help me out on this and post back a correction to

make
it work?

Thanks so much in advance.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default Programming header/footer strings with line feed

I may have it ... I think your mistake is in assuming that CHR(10) is a part
of the text of the string, it is really what CHR(10) evaluates to which is a
part of the string.

Play with this logic in the code, you may see what to do:


'This sets the footer the way you want it (just about)
.LeftFooter = "&""Arial,Bold""&11&UMy Idea" & Chr(10) & "Was This"
'Now set F1 = that result
[F1].Value = .LeftFooter

Take a look at F1 ... you will see it separates the line of text
automatically
So this is how you would enter a value manually into F1 (using
Alt-Enter)

&"Arial,Bold"&11&UMy Idea
Was This


'So now ...
.LeftFooter = [F1].Value works

You have to have the actual line break

"William Benson" wrote in message
...
I recorded this with the macro recorder, maybe it can give you a lead ...


.LeftFooter = "&""Arial,Bold""&11&UMy Idea" & Chr(10) & "Is This"


"XP" wrote in message
...
Thanks Bob,

But if you put that string in a cell in the spreadsheet and then run the
following:

Dim sHeader as string
sHeader = Activecell.Formular1c1
Activesheet.PageSetup.CenterHeader = sHeader

It doesn't work. That is what I'm trying to do...

Thanks for your reply, please help if you can, any ideas?


"Bob Phillips" wrote:

CHR(10) works fine

Just tried this fine

With ActiveSheet.PageSetup
.LeftHeader = "&D" & Chr(10) & "&T"
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"XP" wrote in message
...
I am using Windows XP with Office 2003.

I have a VBA program in which I can enter a header or footer string in
a
sheet and the program enters this string for me into the header or
footer
of
hundreds of files that are formatted automatically. For example a set
up
string might look like:

&"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:

The above would be "Arial", bold, 10-points, underlined. This works
great.

The only thing is, I need to be able to insert a return or a line feed
at
the beginning and/or end of the string and I can't seem to get it to
work.
For example, I tried variations of the following without success:

&Chr(10) &"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:
&"Chr(13)" &"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:

Could someone PLEASE help me out on this and post back a correction to
make
it work?

Thanks so much in advance.









  #6   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Programming header/footer strings with line feed

Thanks William!


"William Benson" wrote:

I may have it ... I think your mistake is in assuming that CHR(10) is a part
of the text of the string, it is really what CHR(10) evaluates to which is a
part of the string.

Play with this logic in the code, you may see what to do:


'This sets the footer the way you want it (just about)
.LeftFooter = "&""Arial,Bold""&11&UMy Idea" & Chr(10) & "Was This"
'Now set F1 = that result
[F1].Value = .LeftFooter

Take a look at F1 ... you will see it separates the line of text
automatically
So this is how you would enter a value manually into F1 (using
Alt-Enter)

&"Arial,Bold"&11&UMy Idea
Was This


'So now ...
.LeftFooter = [F1].Value works

You have to have the actual line break

"William Benson" wrote in message
...
I recorded this with the macro recorder, maybe it can give you a lead ...


.LeftFooter = "&""Arial,Bold""&11&UMy Idea" & Chr(10) & "Is This"


"XP" wrote in message
...
Thanks Bob,

But if you put that string in a cell in the spreadsheet and then run the
following:

Dim sHeader as string
sHeader = Activecell.Formular1c1
Activesheet.PageSetup.CenterHeader = sHeader

It doesn't work. That is what I'm trying to do...

Thanks for your reply, please help if you can, any ideas?


"Bob Phillips" wrote:

CHR(10) works fine

Just tried this fine

With ActiveSheet.PageSetup
.LeftHeader = "&D" & Chr(10) & "&T"
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"XP" wrote in message
...
I am using Windows XP with Office 2003.

I have a VBA program in which I can enter a header or footer string in
a
sheet and the program enters this string for me into the header or
footer
of
hundreds of files that are formatted automatically. For example a set
up
string might look like:

&"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:

The above would be "Arial", bold, 10-points, underlined. This works
great.

The only thing is, I need to be able to insert a return or a line feed
at
the beginning and/or end of the string and I can't seem to get it to
work.
For example, I tried variations of the following without success:

&Chr(10) &"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:
&"Chr(13)" &"Arial,Bold"&10&UACCOUNT SUMMARY CONTINUED:

Could someone PLEASE help me out on this and post back a correction to
make
it work?

Thanks so much in advance.








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
Challenge - Excel Line Feed Character CHR(10) - How to Delete and keep the text formatting without going ro single line in a cell ? No Name Excel Worksheet Functions 7 October 7th 09 11:10 AM
header and footer boarder line Berihu New Users to Excel 1 January 16th 08 12:10 PM
Replace Line Feed nsv Excel Discussion (Misc queries) 7 February 16th 06 04:37 PM
Line Feed Nigel Bennett Excel Programming 2 February 17th 05 07:07 AM
how does excel store new line and line feed characters? ben h[_2_] Excel Programming 0 July 1st 04 02:34 AM


All times are GMT +1. The time now is 02:51 PM.

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

About Us

"It's about Microsoft Excel"