Results 1 to 8 of 8

Thread: Application.Dialogs(xlDialogFormatFont).Show

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Application.Dialogs(xlDialogFormatFont).Show

    I am trying to find some documentation to help implement
    the application.dialogs

    I want to be able to give the user the ability to change the font, font size and style of text they enter in a TextBox on a UserForm

    Thanks

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Application.Dialogs(xlDialogFormatFont).Show

    afaik the font dialog will only change the font settings of the current selection, not any part of a userform

    what you can do is save all the font settings of the selection to variables, then after showing the dialog set the font settings of the textbox, to those of the selection, reset the selection fonts back to original from the saved settings, on closing the userform
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Re: Application.Dialogs(xlDialogFormatFont).Show

    Application.Dialogs(xlDialogFormatFont).Show

    How do I capture the setting values?

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Application.Dialogs(xlDialogFormatFont).Show

    How do I capture the setting values?
    did you read my previous post?
    then after showing the dialog set the font settings of the textbox, to those of the selection
    vb Code:
    1. with textbox1
    2.   .font.name = selection.font.name
    3.   .font.size = selection.font.size
    4.   .font.bold = selection.font.bold
    5.   'etc
    6. end with
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Re: Application.Dialogs(xlDialogFormatFont).Show

    Quote Originally Posted by westconn1 View Post
    did you read my previous post?

    vb Code:
    1. with textbox1
    2.   .font.name = selection.font.name
    3.   .font.size = selection.font.size
    4.   .font.bold = selection.font.bold
    5.   'etc
    6. end with
    Yes I did read your post thanks I cam up with this based on your help
    which seems to be exactly what you posted here


    With Worksheets("Sheet1").Range("AB1").Select
    UserForm1.TextBox2.Font.Name = Selection.Font.Name
    UserForm1.TextBox2.Font.Size = Selection.Font.Size
    UserForm1.TextBox2.Font.Bold = Selection.Font.Bold
    UserForm1.TextBox2.Font.Italic = Selection.Font.Italic

    Application.Dialogs(xlDialogFontProperties).Show

    End With

    I just set the selection to a way off cell and then retrieved the values, its working great

    Thanks for your help

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Application.Dialogs(xlDialogFormatFont).Show

    you actually need to show the dialog before setting the textbox font, so as to pick up the changes
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Re: Application.Dialogs(xlDialogFormatFont).Show

    Ok I seem to have it working except there is a problem if the color is set to automatic I get an error on the last line: "Could Not set the Forecolor property invalid property value"

    Code:
    Worksheets("Sheet1").Range("AC1").Select
      Application.Dialogs(xlDialogFontProperties).Show
        EmailForm.TextBox3.Font.Name = Selection.Font.Name
        EmailForm.TextBox3.Font.size = Selection.Font.size
        EmailForm.TextBox3.Font.Bold = Selection.Font.Bold
        EmailForm.TextBox3.Font.Italic = Selection.Font.Italic
        EmailForm.TextBox3.ForeColor = Selection.Font.ColorIndex
    It appears "automatic" under font color selection in the format cells is a -268......something
    Last edited by billboy; Jun 18th, 2012 at 02:48 PM.

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Application.Dialogs(xlDialogFormatFont).Show

    try
    vb Code:
    1. EmailForm.TextBox3.ForeColor = Selection.Font.Color
    you may need

    vb Code:
    1. if not selection.font.colorindex = -4105 then EmailForm.TextBox3.ForeColor = Selection.Font.Color
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width