Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Excel 4 Macro problem

I want to put cell values into the ge header and then to format heade
text. I have manage to do this using:

With ActiveSheet.PageSetup
.LeftHeader = Range("B52").Value etc

However using this method takes at least 30 seconds for VBA to
set up the page before it will print out. I've tried to use an Excel
macro which I understand is much faster - e.g.:

Application.ExecuteExcel4Macro ("PAGE.SETUP(""&CTEXT"")

This works just putting fixed text into the header, but I have not bee
able to insert the cell value into the header text this way.
There must be a simple solution....

I also wish to format the header text to enlarge and bold it.

Any suggestions?

Pau

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Excel VBA - Excel 4 Macro problem

Paul,

First thing to do is put "ActiveSheet.DisplayPageBreaks = False"
before and after you change PageSetUp. Excel then does not
have to decide where to put them and things can really speed up.

Also, eliminate any PageSetUp settings that you are not changing.

Best would be to have a master/template sheet with the settings already
established and use a copy of that each time you need a new sheet.

If the above doesn't do it for you then using an XL4 macro is a
little faster. But you lose it all in the time it takes to write the code.<g
The following code adds the content of cell D5 to the
center header and makes the font size 12...

'------------------------------------------
Sub TestXL4Macro()
Dim strCenter As String
Dim strSize As String
Dim nn As Long

'font Size
nn = 12
'So XL4 can use it
strSize = "&" & nn
'assign font size to cell value
strCenter = strSize & Range("D5").Value
'put it all together
strCenter = "PAGE.SETUP(" & """&C" & strCenter & """)"
Application.ExecuteExcel4Macro strCenter
End Sub
'-------------------------------------------

Regards,
Jim Cone
San Francisco, CA

"PaulC " wrote in message ...
I want to put cell values into the ge header and then to format header
text. I have manage to do this using:
With ActiveSheet.PageSetup
LeftHeader = Range("B52").Value etc
However using this method takes at least 30 seconds for VBA to
set up the page before it will print out. I've tried to use an Excel 4
macro which I understand is much faster - e.g.:
Application.ExecuteExcel4Macro ("PAGE.SETUP(""&CTEXT"")
This works just putting fixed text into the header, but I have not been
able to insert the cell value into the header text this way.
There must be a simple solution....
I also wish to format the header text to enlarge and bold it.
Any suggestions?
Paul


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Excel 4 Macro problem

Jim

Many thanks "ActiveSheet.DisplayPageBreaks = False" has certainl
solved the delay problem so I don't need to resort to XL4 macros.

I am afraid I still can't seem to reformat the header say to Bold Aria
16pt. I have tried:

"&""Arial,Bold""&16& Range("B52").value

and various combinations of "s and &s to no avail.

Help with this would be much appreciated,

Pau

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Excel VBA - Excel 4 Macro problem

Paul,

This just tested ok for me...

Dim strValue As String
With ActiveSheet.PageSetup
strValue = Range("B52").Value
.CenterHeader = "&""Arial,Bold""&16" & strValue
End With

Regards,
Jim Cone
San Francisco, CA

"PaulC " wrote in message ...
Jim
Many thanks "ActiveSheet.DisplayPageBreaks = False" has certainly
solved the delay problem so I don't need to resort to XL4 macros.
I am afraid I still can't seem to reformat the header say to Bold Arial
16pt. I have tried:
"&""Arial,Bold""&16& Range("B52").value
and various combinations of "s and &s to no avail.
Help with this would be much appreciated,
Paul

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Excel 4 Macro problem

Many, many thanks Jim

Your last suggestion worked perfectly!

Paul


---
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
Excel-Macro Problem SR Excel Discussion (Misc queries) 8 July 20th 07 06:32 AM
Macro problem in Excel pd Excel Discussion (Misc queries) 2 March 14th 06 05:49 AM
problem with macro on Excel Captain Picard Excel Worksheet Functions 0 February 1st 06 09:20 PM
Excel XP macro problem Paul Reeve Excel Programming 1 November 10th 03 11:26 PM
Problem in closing Excel App with translated excel macro Dasharathi K Excel Programming 0 September 19th 03 08:35 AM


All times are GMT +1. The time now is 12:15 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"