Consulting

Results 1 to 16 of 16

Thread: Solved: Speedy PageSetup

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Solved: Speedy PageSetup

    I created a quicker pagesetup with a form and all and I can't get this part to work:

    [VBA]Dim leftHeaderText As String
    Dim centerHeaderText As String
    Dim rightHeaderText As String
    leftHeaderText = PageSetupForm.LeftText.Value
    centerHeaderText = PageSetupForm.CenterText.Value
    rightHeaderText = PageSetupForm.RightText.Value
    With ActiveSheet.PageSetup
    .LeftHeader = "&""Arial,Bold" & leftHeaderText
    .CenterHeader = "&""Arial,Bold" & centerHeaderText
    .RightHeader = "&""Arial,Bold""&12 " & rightHeaderText
    End With[/VBA]

    I get Arial, bold as my headers

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I'm really lost Daniel.....you formatted the header as Arial Bold and then you question why that is the result.....
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Private Sub CommandButton1_Click()
    Dim leftHeaderText As String
    Dim centerHeaderText As String
    Dim rightHeaderText As String
    leftHeaderText = PageSetupForm.LeftText.Value
    centerHeaderText = PageSetupForm.CenterText.Value
    rightHeaderText = PageSetupForm.RightText.Value
    With ActiveSheet.PageSetup
    .LeftHeader = "&""Arial,Bold""&12" & leftHeaderText
    .CenterHeader = "&""Arial,Bold""&10" & centerHeaderText
    .RightHeader = "&""Arial,Bold""&12" & rightHeaderText
    End With

    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Thank you mdmack,

    Sometimes I feel like an idiot!!! lol

  5. #5
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Another problem with speedy page setup

    I have created a function of my add-in to do a quick page setup formating and part of it checks what is in the right header, center header, and left header already and populates my form but it is also picking up the formating. How do I stop it from picking up the formating also? This is what I have:

    [VBA]Private Sub UserForm_Initialize()
    LeftText.Value = ActiveSheet.PageSetup.LeftHeader
    CenterText.Value = ActiveSheet.PageSetup.CenterHeader
    RightText.Value = ActiveSheet.PageSetup.RightHeader
    End Sub[/VBA]

  6. #6
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    What do you mean it's picking up the format?

    As far as I'm aware if you populate a textbox's value then that's all you do - the format doesn't come across.

  7. #7
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    This is what I am getting (&"Arial,Bold"&10&"Arial,Bold"&10test) The code for the page formating.

  8. #8
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I merged these threads Daniel. You are confusing folks and expecting them to know what has been going on in other posts.....you should have added your followup question to the existing thread to cut down on the confusion.......
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  9. #9
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Sorry lucas i would have but I marked it as solved and I haven't figured out how to trun off the sloved yet.

  10. #10
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Daniel,
    Can you post a sample, otherwise I (and anyone else) has to create one to test out what you're saying to try and find a solution.
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  11. #11
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Daniel

    Why do you find this unusual?

    Those are the values of those properties.

  12. #12
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Ok, Madmack

    Norie, not necesarrily unusual I just don't want to see the formating also

  13. #13
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Here is the test book

  14. #14
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Daniel,
    This should strip off the font description and size. There will be problems if your header starts with a number. I've not found a way to return the header font size, which otherwise could be used.



    [VBA]Private Sub UserForm_Initialize()

    LeftText.Value = GetText(ActiveSheet.PageSetup.LeftHeader)
    CenterText.Value = GetText(ActiveSheet.PageSetup.CenterHeader)
    RightText.Value = GetText(ActiveSheet.PageSetup.RightHeader)

    End Sub

    Function GetText(txt As String)
    Dim Arr, i As Long
    If txt = "" Then
    GetText = ""
    Exit Function
    End If
    Arr = Split(txt, Chr(34))
    txt = Arr(UBound(Arr))
    If Left(txt, 1) = "&" Then
    i = 2
    Do Until IsNumeric(Mid(txt, i, 1)) = False
    i = i + 1
    Loop
    i = i - 1
    End If
    GetText = Right(txt, Len(txt) - i)
    End Function
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  15. #15
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Thank you for the help. that works perfect

  16. #16
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Daniel...You can remove the solved: by using the thread tools at the top of the page and select edit thread....just remove the solved: from the title and save the changes.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •