0

I want to highlight syntax for my programming language of choice (proprietary) in Microsoft OneNote 2013 with a macro or script. I found a free Macro creator for MS OneNote '13 that allows creation of custom macros called "OneTastic". I created a macro that is given two arrays with lists of predefined words associated with different colors to give each list (ex: List 1 words = blue, list 2 words = orange, etc.)

API: https://www.omeratay.com/onetastic/docs/

Problem: The search logic is finding words inside of bigger words, like "IN" inside of the word "domain" (domaIN). My code is below:

<?xml version="1.0" encoding="utf-16"?>
<Macro name="CCL TEST 3" category="Color" description="" version="10">
  <ModifyVar name="KEYWORDS1" op="set">
    <Function name="String_Split">
      <Param name="string" value="drop create program go %i declare call set end END execute else elseif protect constant curqual of subroutine to noconstant record free range in is protect define macro endmacro" />
      <Param name="delimiter" value=" " />
    </Function>
  </ModifyVar>
  <ModifyVar name="counter" op="set" value="0" />
  <WhileVar name="counter" op="lt">
    <Function name="Array_Length">
      <Param name="array" var="KEYWORDS1" />
    </Function>
    <IsRootOp />
    <ModifyVar name="keyword" op="set" var="KEYWORDS1">
      <RightIndex var="counter" />
    </ModifyVar>
    <For each="Text">
      <That hasProp="value" op="eq" var="keyword" />
      <ModifyProp name="fontColor" op="set" value="blue" />
    </For>
    <ModifyVar name="counter" op="add" value="1" />
  </WhileVar>
  <ModifyVar name="KEYWORDS2" op="set">
    <Function name="String_Split">
      <Param name="string" value="datetimefind datetimediff cnvtdatetime cnvtalias format build concat findfile error alterlist alter initrec cnvtdate esmError echo max min avg sum count uar_get_code_meaning mod substring size trim hour day isnumeric expand locateval cnvtstring fillstring btestfindstring logical uar_get_code_display uar_get_meaning_by_codeset UAR_GET_CODE_BY sqltype cnvtreal echorecord cnvtupper cnvtlower cnvtdatetimeutc abs datetimediff year julian btest decode evaluate findstring asis replace validate nullterm parser value uar_timer_create uar_CreatePropList uar_SetPropString uar_CloseHandle uar_Timer_Destroy uar_Timer_Stop build2 patstring piece cnvtalphanum timestampdiff" />
      <Param name="delimiter" value=" " />
    </Function>
  </ModifyVar>
  <ModifyVar name="counter2" op="set" value="0" />
  <WhileVar name="counter2" op="lt">
    <Function name="Array_Length">
      <Param name="array" var="KEYWORDS2" />
    </Function>
    <IsRootOp />
    <ModifyVar name="keyword" op="set" var="KEYWORDS2">
      <RightIndex var="counter2" />
    </ModifyVar>
    <For each="Text">
      <That hasProp="value" op="eq" var="keyword" />
      <ModifyProp name="fontColor" op="set" value="orange" />
    </For>
    <ModifyVar name="counter2" op="add" value="1" />
  </WhileVar>
</Macro>

OneTastic Syntax Highlighter Script

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
Doug Wilhelm
  • 776
  • 9
  • 26

2 Answers2

0

There is no such inbuilt feature available in OneNote but you can do it.

Use Visual Studio Code, it's free. Turn on right text copy/pasting. Write your code in in VS code. Copy it. It'll paste exactly as you see. Colors and all.

Cool Goose
  • 870
  • 10
  • 16
0

While this does not use VBA, I use and love the add-in NoteHightlight2016

If you don't find a language you can go through and add your own. I've added the Excel Formula keywords to the languages supported and I believe it is a bit easier than creating in OneTastic, which I also use and love.

Kevin Scharnhorst
  • 721
  • 1
  • 7
  • 14