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

I assume your 'usual way' of creating a macro is to record it: this is
actually a terrible way to create non-trivial macros, for precisely the
reason you've discovered the hard way. The problem is that your macro
assumes that you have a table selected when you call the macro; your macro
then sorts the selection. But when you use your macro button, you don't have
a table selected.

You'll need to explain what you're actually trying to do if you want good
suggestions about how to do it.




"BobW" wrote in message
...
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"