Share via

multi replace macro with drop down menu for entering music values

Anonymous
2016-05-15T14:22:14+00:00

sorry if this request is redundant! I am a musician that needs to change keys and consequently chords from one key to another using MS Word 2007. These replacements would involve multiple find and replacement values that change from one document to another. I only want to work with one document at a time. I would like to invoke a macro to include a drop down menu box so i could input approximately 7 different values into the find and replace sections (separated by a comma) to make the proper key changes. This may be a combination of previous macros but I can't seem to put them all together. This is an example of what I need:

Task: Change chords from the key of "A" to the Key of "E" : 

Find: A, B, C♯, D, E, F♯, G♯

Replace: E♭, F, G, A♭, B♭, C, D

Thank you so much

Steve

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

17 answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2016-05-17T23:29:06+00:00

    OK, I can see an issue with the code I provided because in the above case (unless there is an error in the example), the first C is being replaced by C and the second one is being replaced by Bb7

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-05-17T18:25:23+00:00

    Hi Rohn007,

    While you are perfectly correct in MS Word being a difficult way of expressing music notation. It is just the chord text I am dealing with so for example:

    If I have a musical text line that reads like this:

    E           Am7  C     B7                    C           B7   C7    B7

    Michelle,      ma      belle,  these are words that go together well, my Michelle.

    And I want to change key from “E” to “D”. All that is required from the MACRO is changing (find & replace) the Letters like so:

    D             Gm7  Bb    A7                   Bb           A7  Bb7   A7

    Michelle,       ma     belle,  these are words that go together well, my Michelle.

    All else stays the same including the symbol for a flat is the small case letter “b” and a sharp is a pound symbol “#” . Note that changing Keys is transposing six letters (sometimes with an added “flat or sharp” symbol) to six other letters in a different key.

    Example:

    Find: Key of "A" = A, B, C#, D, E, F#, G#

    Replace: Key of "Eb" = Eb, F, G, Ab, Bb, C, D

    The key changes are represented in a table which can be many different combinations of which I can cut and paste into an appropriately defined drop-down menu (User Input in a Dialog Box).

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2016-05-17T17:37:33+00:00

    Doug,

    Since I am relatively new to this, I am struggling to get the results I expected. I will continue to work this macro until it comes out as expected. I still am looking for the drop down menu to appear when I invoke the macro but it looks like I have keep changing the input strings in the VBE for each key change. I hope we can still work together until this is complete. I greatly appreciate you efforts and help.

    Steve

    Was this answer helpful?

    0 comments No comments
  4. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2016-05-16T03:49:40+00:00

    Try

    Dim i As Long

    Dim arrFind As Variant

    Dim arrReplace As Variant

    arrFind = Split(InputBox("Enter each letter to be replaced, separated by a space"))

    arrReplace = Split(InputBox("Enter the replacements in the same order with each one separated by a space"))

    If UBound(arrFind) <> UBound(arrReplace) Then

        MsgBox "You have not entered the same number if items to be found and their replacements."

        Exit Sub

    End If

    For i = LBound(arrFind) To UBound(arrFind)

        With ActiveDocument.Range

            .Text = Replace(.Text, arrFind(i), arrReplace(i))

        End With

    Next i

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2016-05-15T16:41:13+00:00

    This is pushing Find/Replace.

    How do you represent this music, specifically chords in Word? Word is a very unnatural way of recording music notation. Unless you know something I don't (which would not be a surprise to me ... <grin> )

    If you already know of a way to do this change for a single cord, how do you do it.  Is the find/replace example exactly how you currently would do one of these replacements? (Are those are exactly the find/replace criteria you already use?)

    I don't have a complete answer to your question, but maybe you can piece together something from these clues.

    This tip describes how to get user inputs in to a macro (if find/replace criteria)

    Getting User Input in a Dialog Box

    http://word.tips.net/Pages/T001356_Getting_User_Input_in_a_Dialog_Box.html

    Find & Replace has Multiple Search Options

    Word's Find/Replace uses two entirely separate search engines: simple text find and wildcard find.

    The more familiar engine is adequate for very specific or very general targets ("Massachusetts" or "*"), but the lesser known engine is much more powerful, and  can track down and modify subtler targets such as any date, any time, or any dollar value.

    To toggle between the two, check or uncheck Pattern Match.  For documentation, read the help-file page entitled "Examples of search wildcards" (in the Word97 help file search index, look for "Searching", choose the subtopic "Wildcards", and then click the "How" button under bullet 4).

    For key differences between the two Find engines, see http://support.microsoft.com/support/kb/articles/Q176/7/76.asp

    Word's Find/Replace uses two entirely separate search engines: simple text find and wildcard find.

    Take a look at the tool mentioned in this tip:

    Saving Find and Replace Operations – batch replace multiple files

    http://wordribbon.tips.net/T011136_Saving_Find_and_Replace_Operations.html

    Was this answer helpful?

    0 comments No comments