runofthemill
01-16-2013, 03:15 PM
Hello,
I'm trying to figure out how to code a macro to insert specific text at the beginning of each line of a user-defined selection. In essence, the user selects part of a list (defined as one item per line) and clicks a button to run the macro, which tags each item in that list.
The problem I am having is that I cannot figure out how to define the length of a loop if it's based on the length of a user selection. Each iteration of the loop should do this:
Selection.HomeKey Unit:=wdLine
Selection.TypeText Text:="[Repeat SKU] "
Selection.MoveDown Unit:=wdLine, Count:=1
Should I be passing the selection into a range object? I'm a bit of a VBA novice here, and any and all help is very much appreciated. Thanks!
I'm trying to figure out how to code a macro to insert specific text at the beginning of each line of a user-defined selection. In essence, the user selects part of a list (defined as one item per line) and clicks a button to run the macro, which tags each item in that list.
The problem I am having is that I cannot figure out how to define the length of a loop if it's based on the length of a user selection. Each iteration of the loop should do this:
Selection.HomeKey Unit:=wdLine
Selection.TypeText Text:="[Repeat SKU] "
Selection.MoveDown Unit:=wdLine, Count:=1
Should I be passing the selection into a range object? I'm a bit of a VBA novice here, and any and all help is very much appreciated. Thanks!