View Single Post
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
BobW
 
Posts: n/a
Default macro runs from keyboard, but not from macro button-why?

I created a macro to sort a table by column 2, which is filled with numbers.
I used the usual method of creating a macro - Word's macro "wizard" .

The macro runs OK when executed via the keyboard shortcut I assigned.

But if I create a macrobutton at the top of the column to run the same
macro, it refuses to execute; when I double click on the macrobutton field, I
get "Visual Basic Run Time error 9125 - String Passed Can't Be Parsed".

How can a macro string execute perfectly from keyboard, but not from a
macrobutton?

Here's the 'problem' string that the wizard generated - does if offer any
clues?

Selection.Sort ExcludeHeader:=True, FieldNumber:="Column 2", SortFieldType _
:=wdSortFieldNumeric, SortOrder:=wdSortOrderAscending,
FieldNumber2:="", _
SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:=wdSortOrderAscending _
, FieldNumber3:="", SortFieldType3:=wdSortFieldAlphanumeric,
SortOrder3:= _
wdSortOrderAscending, Separator:=wdSortSeparateByCommas,
SortColumn:= _
False, CaseSensitive:=False, LanguageID:=wdEnglishUS,
SubFieldNumber:= _
"Paragraphs", SubFieldNumber2:="Paragraphs", SubFieldNumber3:= _
"Paragraphs"