Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Using Flag Variables in Macros?

I have a macro that I use to format blocks of text with several different formats. It formats the two header rows correctly, but then it starts to work incorrectly.

After it formats a single line of text it then formats a list for a specific number of lines. I'd like it to search for a flag variable and only continue formatting as it had been until it found the flag variable. Is there a way I can get it to search for this flag variable?

It seems like it would be an if-then-else statement, but I'm not sure what to use as the test criteria. I currently have:

dim desiredSelection as string

desiredSelection="Directions"

If Selection.Text = "Directions" Then

'some actions

else

If [Selection.Text] <> desiredSelection Then

'more actions

end if

Here is the code that formats the list:

'edits the ingredients body

Selection.MoveDown Unit:=wdLine, Count:=5

Selection.MoveLeft Unit:=wdWord, Count:=2, Extend:=wdExtend

Selection.MoveUp Unit:=wdParagraph, Count:=4, Extend:=wdExtend

Selection.Font.Name = "Segoe Print"

Selection.Font.Size = 10

Selection.MoveDown Unit:=wdLine, Count:=1

Selection.EndKey Unit:=wdLine

Selection.HomeKey Unit:=wdLine

Selection.EndKey Unit:=wdStory

Selection.MoveUp Unit:=wdLine, Count:=6

Selection.EndKey Unit:=wdLine, Extend:=wdExtend

1 Answer

Relevance
Still have questions? Get your answers by asking now.