Results 1 to 11 of 11
  1. #1
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Special formatting (97-->)

    An associate of mine is a musician and has got an unusual problem. I don't quite understand music notation so will explain it in laymans terms


    He wants it in the notation below my signature.

    I thought I would get him to type the following 2#10 (for the top one) #102 for the latter. When he wanted to format it, highlight the selection and a macro would interpret the # to box the number 10 and the to superscript.

    Can't quite get my head around the code, can you help me, I have created the superscript one but can't do the box part and can't work out how to get the selected string to know what to do when it finds the or #
    Jerry

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Special formatting (97-->)

    This works in Word 2002 (Office XP): select your number 10 with the mouse, call up Format>Borders and Shading..., make sure "text" is selected in the "Apply to" drop-down, click any of the border buttons around the drawing, then OK. Does it create the box you want?

    To generate code for this, I recommend the macro recorder. It might include lots of useless stuff that you can delete, but it should show the critical elements that you need. Also, the default interior margins seem rather narrow. It's not clear that you can alter them for a text selection, but maybe something in the recorded code will show a way?

  3. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Special formatting (97-->)

    Thanks Jeff

    I have been writing this tonight:

    Sub BoxIt()

    With Selection.Font
    With .Borders(1)
    .LineStyle = wdLineStyleSingle
    .LineWidth = wdLineWidth050pt
    .Color = wdColorAutomatic
    End With
    .Borders.Shadow = False
    End With
    With Options
    .DefaultBorderLineStyle = wdLineStyleSingle
    .DefaultBorderLineWidth = wdLineWidth050pt
    .DefaultBorderColor = wdColorAutomatic
    End With
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    With Selection.ParagraphFormat
    .Borders(wdBorderLeft).LineStyle = wdLineStyleNone
    .Borders(wdBorderRight).LineStyle = wdLineStyleNone
    .Borders(wdBorderTop).LineStyle = wdLineStyleNone
    .Borders(wdBorderBottom).LineStyle = wdLineStyleNone
    With .Borders
    .DistanceFromTop = 1
    .DistanceFromLeft = 4
    .DistanceFromBottom = 1
    .DistanceFromRight = 4
    .Shadow = False
    End With
    End With
    With Options
    .DefaultBorderLineStyle = wdLineStyleSingle
    .DefaultBorderLineWidth = wdLineWidth050pt
    .DefaultBorderColor = wdColorAutomatic
    End With
    End Sub
    ------------------------------------------

    Sub SuperScript()
    With Selection.Font
    .SuperScript = True
    .Subscript = False

    End With
    End Sub

    Superscript is fine, BoxIt seems a bit of a nuisance as once I have selected the text and run the code I can't seem to get rid of the borders and it keeps putting them around them. I have got a feeling the person is not going to like it as I have a feeling they were looking for an autoformat option... I am still going but if you have any other ideas let me have 'em <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Jerry

  4. #4
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Special formatting (97-->)

    Is the '10' always 10? - or could it be any number of an infinite number of numbers?

  5. #5
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Special formatting (97-->)

    Sorry for the delay getting back.

    In my example the 2 can be any number and the 10 could be any number, but not to infinity as they apparently denote bar numbers in the score sheet
    Jerry

  6. #6
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Special formatting (97-->)

    Oh yes I have just realised my idea in the question needs to be tweaked as I have just realised I can't use a # as this is a sharp symbol in music and I can imagine there would be a lot of those if he is a composer
    Jerry

  7. #7
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Special formatting (97-->)

    Hmmmm. I was going to suggest something like AutoCorrect, where you type something like 10bx and it automatically replaces it with a boxed 10.
    Attached Images Attached Images
    • File Type: gif x.gif (3.9 KB, 0 views)

  8. #8
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Special formatting (97-->)

    No that sounds as though it has legs, I'll pop off and have a go <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Jerry

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Special formatting (97-->)

    I would skip the idea of special codes and just provide two keyboard shortcuts. There is already one for superscript: Ctrl+Shift+=. For the other one., let him select Tools | Customize... and press Keyboard. Selet the All Commands category, then the command BordersOutside. Click in the "Press new shortcut key" box and press (for example) Ctrl+Alt+B, then click Assign.
    He can now select a number and press Ctrl+Shift+= to superscript it, or Ctrl+Alt+B to box it.

  10. #10
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Special formatting (97-->)

    Leif

    A revelation, it appears that I may have been going about this the wrong way. If this guy has wriiten his essay/composition. In word he could use the formatting toolbar. It can easily be set up, type a word, Format|Borders and Shading| set your lines for Text|OK. After that he just has to use the format bar. Why make it difficult. Thanks Jeff and Leif, I think that will do for tonight.
    Jerry

  11. #11
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Special formatting (97-->)

    Thanks Hans

    I think I may have cracked it. I set up a format, Normal text +Border then wrote three cdes assigned to the keyboard:

    Ctrl+1 to create the superscript

    Sub SuperScript()
    With Selection.Font
    .SuperScript = True
    .Subscript = False

    End With
    End Sub

    Ctrl+2 to create the boxed format

    Sub BoxIt()
    '
    ' BoxIt Macro
    ' Macro recorded 28/06/2005 by Jerry
    '
    With Selection.Font
    With .Borders(1)
    .LineStyle = wdLineStyleSingle
    .LineWidth = wdLineWidth050pt
    .Color = wdColorAutomatic
    End With
    .Borders.Shadow = False
    End With
    With Options
    .DefaultBorderLineStyle = wdLineStyleSingle
    .DefaultBorderLineWidth = wdLineWidth050pt
    .DefaultBorderColor = wdColorAutomatic
    End With
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    With Selection.ParagraphFormat
    .Borders(wdBorderLeft).LineStyle = wdLineStyleNone
    .Borders(wdBorderRight).LineStyle = wdLineStyleNone
    .Borders(wdBorderTop).LineStyle = wdLineStyleNone
    .Borders(wdBorderBottom).LineStyle = wdLineStyleNone
    With .Borders
    .DistanceFromTop = 1
    .DistanceFromLeft = 4
    .DistanceFromBottom = 1
    .DistanceFromRight = 4
    .Shadow = False
    End With
    End With
    With Options
    .DefaultBorderLineStyle = wdLineStyleSingle
    .DefaultBorderLineWidth = wdLineWidth050pt
    .DefaultBorderColor = wdColorAutomatic
    End With
    End Sub

    Ctrl+3 to convert back to Normal text

    Sub RidBox()

    Selection.TypeText Text:=" "
    Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    Selection.Style = ActiveDocument.Styles("Normal")
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    End Sub

    Probably reinvented the wheel but I have been working on this for a few hours and didn't want to get beaten. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> everyone
    Jerry

Posting Permissions

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