V
vf007
Hello,
I'm working on a macro to transpose keys in song sheets.
Sub TransposeKeys()
Dim MusicNotesArray(11) As String
MusicNotesArray(0) = Chr(65) 'A
MusicNotesArray(1) = Chr(66) & Chr(98) 'Bb
MusicNotesArray(2) = Chr(66) 'B
MusicNotesArray(3) = Chr(67) 'C
MusicNotesArray(4) = Chr(67) & Chr(35) 'C#
MusicNotesArray(5) = Chr(68) 'D
MusicNotesArray(6) = Chr(69) & Chr(98) 'Eb
MusicNotesArray(7) = Chr(69) 'E
MusicNotesArray(8) = Chr(70) 'F
MusicNotesArray(9) = Chr(70) & Chr(35) 'F#
MusicNotesArray(10) = Chr(71) 'G
MusicNotesArray(11) = Chr(65) & Chr(98) 'Ab
'define actual page as a range
Dim MyRange As Range
Set MyRange = Selection.Range
Set MyRange = MyRange.GoTo(What:=wdGoToBookmark, Name:="\page")
'replace strings only in specified style
MyRange.Find.ClearFormatting
MyRange.Find.Style = ActiveDocument.Styles("Título 2")
MyRange.Find.Replacement.ClearFormatting
With MyRange.Find
.Text = MusicNotesArray(5) 'just an example
.Replacement.Text = MusicNotesArray(9) 'just an example
.MatchCase = True
.Forward = True
.Wrap = wdFindStop
End With
MyRange.Find.Execute Replace:=wdReplaceAll
End Sub
Now i'm working on a code to find and replace all ocuurences of the
musical scale in a song (sorry about my english).
My very hard problem is turn my code inteligent. For example, the code
must to find "C" and replace to "D"; "Am7" to "Bm7", etc. I'm not
considering de variations of the chords (m7, º, 7M, etc), only the #'s
and b's). The problem is if I have:
C Am7 F D#mº
onono onono nonon nonono ono
It will turned to
D Bm7 G Eb#m <- THIS CHORD IS INCORRECT!
onono onono nonon nonono ono
How to identify those chords with # or b and to avoid its incorrect
transposition?
Regards.
VFrar
I'm working on a macro to transpose keys in song sheets.
Sub TransposeKeys()
Dim MusicNotesArray(11) As String
MusicNotesArray(0) = Chr(65) 'A
MusicNotesArray(1) = Chr(66) & Chr(98) 'Bb
MusicNotesArray(2) = Chr(66) 'B
MusicNotesArray(3) = Chr(67) 'C
MusicNotesArray(4) = Chr(67) & Chr(35) 'C#
MusicNotesArray(5) = Chr(68) 'D
MusicNotesArray(6) = Chr(69) & Chr(98) 'Eb
MusicNotesArray(7) = Chr(69) 'E
MusicNotesArray(8) = Chr(70) 'F
MusicNotesArray(9) = Chr(70) & Chr(35) 'F#
MusicNotesArray(10) = Chr(71) 'G
MusicNotesArray(11) = Chr(65) & Chr(98) 'Ab
'define actual page as a range
Dim MyRange As Range
Set MyRange = Selection.Range
Set MyRange = MyRange.GoTo(What:=wdGoToBookmark, Name:="\page")
'replace strings only in specified style
MyRange.Find.ClearFormatting
MyRange.Find.Style = ActiveDocument.Styles("Título 2")
MyRange.Find.Replacement.ClearFormatting
With MyRange.Find
.Text = MusicNotesArray(5) 'just an example
.Replacement.Text = MusicNotesArray(9) 'just an example
.MatchCase = True
.Forward = True
.Wrap = wdFindStop
End With
MyRange.Find.Execute Replace:=wdReplaceAll
End Sub
Now i'm working on a code to find and replace all ocuurences of the
musical scale in a song (sorry about my english).
My very hard problem is turn my code inteligent. For example, the code
must to find "C" and replace to "D"; "Am7" to "Bm7", etc. I'm not
considering de variations of the chords (m7, º, 7M, etc), only the #'s
and b's). The problem is if I have:
C Am7 F D#mº
onono onono nonon nonono ono
It will turned to
D Bm7 G Eb#m <- THIS CHORD IS INCORRECT!
onono onono nonon nonono ono
How to identify those chords with # or b and to avoid its incorrect
transposition?
Regards.
VFrar