Consulting

Results 1 to 7 of 7

Thread: How can I open the Modify Style dialog box in Word Visual Basic?

  1. #1

    How can I open the Modify Style dialog box in Word Visual Basic?

    Application.Dialogs(?).Show

  2. #2
    It appears that you can't, but as you are presumably programming styles in VBA, iut shouldn't be necessary. You can simply address the style directly, and if you need to get a value from a user, then employ an input box or a userform.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    Sub ScratchMacro()
    'A basic Word macro coded by Greg Maxey
    MsgBox "One would think that wdDialogEditStyle would be the ticket. It isn't. This will work though:"
    Application.Dialogs(1347).Show
    lbl_Exit:
    Exit Sub
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  4. #4
    Thanks, that works. You must be very smart. I never would have guessed 1347.
    Can you tell me the purpose of the lbl_Exit: label in your subprogram?

  5. #5
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    Bob,

    In this case no purpose really. It is just my unorthodox coding style. If I had an error handler it might look like this:
    Sub ScratchMacro()
     'A basic Word macro coded by Greg Maxey
        On Error GoTo Err_Handler
      MsgBox "One would think that wdDialogEditStyle would be the ticket.  It isn't.  This will work though:"
         Application.Dialogs(1347).Show
     lbl_Exit:
        Exit Sub
     Err_Handler:
      Msgbox Err.Number
      Resume lbl_Exit
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  6. #6

    Dialogs(1347) works -- almost

    Quote Originally Posted by gmaxey View Post
    Sub ScratchMacro()
    'A basic Word macro coded by Greg Maxey
    MsgBox "One would think that wdDialogEditStyle would be the ticket. It isn't. This will work though:"
    Application.Dialogs(1347).Show
    lbl_Exit:
    Exit Sub
    End Sub

    The dialog 1347 works, but I'm finding that when I try to change formats other than those that appear on the first page (e.g. paragraph formatting) it does not save. Any suggestions?
    Thanks

  7. #7
    VBAX Newbie
    Joined
    Feb 2020
    Posts
    1
    Location
    This is a clumsy method, but it works, at least if run as a macro from within the text of the document, e.g. using a custom keyboard shortcut. (It depends on keyboard shortcut Alt+' being set to bring up the "Style" dialog box - I can't remember whether that was something I set up ages ago, or is the default - but the %' in each SendKeys statement could be modified to match whatever the shortcut is for you.)

    If ActiveDocument.Styles(Selection.Style).BuiltIn Then
    SendKeys "%'{tab}{tab}{enter}"
    Else
    SendKeys "%'{tab}{tab}{tab}{enter}"
    End If

Posting Permissions

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