Color VB Comments

Description : Changes color of text starting with a single quote (') on selected lines to green

Download

Color VB Comments


You need Onetastic Add-in
for OneNote to run this macro.
Download Onetastic
Author(s) : Omer Atay
Category : Formatting
Last Updated : October 17, 2016
Rating :
(0)
Download(s) : 68
Screenshot :

Color VB Comments

No screenshot available for this macro.
Changelog :

October 17, 2016 (E9FA79) - Omer Atay
Initial version

Comments

Name
Comment
Dan - 2017-01-25
Hello Omer,
what if I wrapped my word at both ends eg    %Hello% would a macro be able to isolate or identify that word using the index of characters?
If string contains characters start position?
Omer Atay - 2017-01-22
Dan: Macros currently don't have a way to query whole words or otherwise identify word boundaries. Therefore writing this kind of macro that has to deal with words is very hard.
Dan - 2017-01-22
Hello Omer,

I would like to Change the Font Color of words that have a % in front of them,

I know this is a lot to ask but I would be really grateful, please  please can you help me to adapt this so I can color my words.

<?xml version="1.0" encoding="utf-16"?>
<Macro name="Color VB Comments -Omer" category="TEST" description="Changes color of text starting with a single quote (') on selected lines to green" publishDate="00-00-00T00:00:00.000Z" version="15">
  <Comment text="----------------------------------------------------------------------------------" />
  <Comment text="    Color Words" />
  <Comment text="----------------------------------------------------------------------------------" />
  <Expression>$color = "#FF0099"</Expression>
  <Comment text="Find all the selected paragraphs" />
  <ForEach var="p">
    <Array>QueryObjects("Text", GetCurrentPage())</Array>
    <Comment text="Find quotes as the beginning of a comment" />
    <Expression>$quotes = QueryText($p, "%", false)</Expression>
    <If>
      <Condition>Array_Length($quotes) == 0</Condition>
      <Continue>1</Continue>
    </If>
    <Comment text="Start coloring from the first quote " />
    <Expression>$quote = $quotes[0]</Expression>
    <Expression>$quote.fontColor = $color</Expression>
    <Comment text="Get all the text in the paragraph and color the ones that are after the first quote" />
    <ForEach var="text">
      <Array>QueryObjects("Text", $p)</Array>
      <If>
        <Condition>$text.startIndex &gt; $quote.startIndex</Condition>
        <Expression>$text.fontColor = $color</Expression>
      </If>
    </ForEach>
  </ForEach>
</Macro>


I have been trying for months and cant make it work :( :(
I have left the original as above as I cant work out how to isolate the words with a % in front of them.
Normally I have to copy and paste to word - and then paste back and I have too many pages to do everyday

When ever you have a chance thank you so much