Onetastic for Microsoft OneNote Onetastic Macroland
  • HOME
  • MACROLAND
  • BLOG
  • ONECALENDAR
  • DOWNLOAD
  • CHANGELOG
  • FAQ
  • CONTACT
  • MY ACCOUNT
  • RSS RSS
YOU CAN NOW DOWNLOAD MACROS FROM MACROLAND. CHECK IT OUT!

ALL POSTS

  • Macros beyond Current Page and Macroland, a repository for Macros
  • OneNote SkyDrive Sync - Why you shouldn't use other...
  • Onetastic and OneCalendar Now Available in German
  • Onetastic and OneCalendar Now Available in Chinese and Turkish
  • How to Set up Shortcuts for Macros
  • Translate Onetastic into Your Own Language
  • Macro Tutorial - Inserting Text
  • Error Reporting
  • Macro Tutorial
  • Function macro
  • Extending possibilities with Macros
  • Rearranging Ribbon Buttons and Auto-scale
  • Update for OneCalendar: Page Previews and Scrolling
  • Update for Onetastic: Select Text from Image
  • Update for Onetastic: Favorites and Custom Styles
  • Update for Onetastic: Pin to Desktop, Improvements, Bug Fixes
  • Update for OneCalendar: Settings, Keyboard shortcuts, Go to Today
  • The Stubborn Docked Window
  • New Feature: Image Crop
  • What is Onetastic?

Donate
for future development of Onetastic
(Why?)

Sep 20
2012
Macro Tutorial

Macros are built using the Macro Editor which can be launched from New Macro or Edit Macros buttons on the ribbon. See this post for more details. Macro Editor looks like below:

Macro editor

Here you can set the name, category and description of the macro and below that you can see the set of commands at your disposal on the left and the macro you are building on the right. You can use the Add and Remove buttons to build your macro. Before diving into all the details here, let's take a look at a simple macro and see how macros are built and how they work. Then we can slowly move into more aspects of macros.

Finding and modifying objects

This macro increases font size of all text on the current page by 1pt. The macro looks like this:

Macro screenshot - Modify Properties

As simple as that. The macro finds text in the current page and modifies its "fontSize" property by adding 1 to it. The blue underlined parts are pieces you can click and change to edit the macro. For instance you can click on "Text" and pick a different object type:

Macro screenshot - Modify Properties

Similarly you can pick the property you want to modify and how you want to modify.

Using conditions to filter objects

When querying for objects on the page, you can make use of conditions which are in the form of:

Macro screenshot - Filter objects

For example if you want to find paragraphs that are edited by "John" and are inside a table which is partially selected, you can do so by:

Macro screenshot - Filter objects

You can combine the "Is under" and "That has" to build more complex conditions. You can add as many of them as you need to specify the objects you are interested in.

Using variables for temporary storage

You can make use of variables, for temporarily storing and manipulating information. For instance if you want to read the text in a table cell and fill the rest of the table with that text, you can temporarily store the text of the first cell in a variable:

Macro screenshot - Variables

This macro stores the "text" property of the first table cell in to a variable named "TextOfFirstCell" and then reuses that to set the text for all the table cells. To add more variables or use existing variables, simply click on the blue underlined part in the Modify line and choose one of the options:

Macro screenshot - Variables

As you can see, you can choose either a property or a variable (existing or new) to modify here.

Using conditions to selectively apply modifications

You may want to apply modifications based on different conditions. The "That has" and "Is under" filters somewhat give you that but once that filter applied and you have the set of objects you can't make further decisions using them. To provide this, you can use If/Else clauses. Let's say you want to highlight text based on author:

Macro screenshot - Conditions

You can build very complex conditional statements using these and selectively apply any modifications. "If" can also evaluate conditions on variables and can use one or more of the following conditional operators, based on the values compared:

Macro screenshot - Conditions

Using indices to store set of values in variables

Macros support storing a set of values in variables as pairs. Indices are the way to achieve this. To explain that let's use an example: Copy the values of the first row into the second row in a table.

Macro screenshot - Indices

Here we check the "rowIndex" property of each cell. The first row is where rowIndex is 0, and the second row is where rowIndex is 1. We store text from each cell in the first row in the variable named "Text", indexed by the column index (colIndex property). This way we can store the text from the first row as pairs and then reuse it in the next row to set the text for the second row. To add an index to a variable use the "Add index to variable X" option on the variable selector:

Macro screenshot - Indices

This will add the index and you can then choose what to use as an index.

Using constant literal values

You can use constant literal values in the right hand side of That/Modify/If clauses. In fact we already did in most of the above examples. When you click to change the right-hand-side, you will see the list of properties and variables and an option to "Enter literal value". Also if the left-hand-side is a property with known set of values, you will see them there:

Macro screenshot - Literals

Here selection property can be one of "none", "partial" or "all", so you get to choose from one of them. Alternatively you can enter the value manually.

Asking user for input

You can ask user for input during macro execution to modify behavior of the macro. To do so, add a Modify clause and choose a variable for the left-hand-side. For the right hand side choose "Prompt user for value". This will open a dialog to enter details of the user input. For instance if you are building a macro that will search for some text (e.g. Search and replace) you may ask the user for the search term:

Macro screenshot - User Prompts

Macro screenshot - User Prompts

Here you can:

  • Add a message for the user (or choose a variable that contains the message),
  • Choose input type which can be one of
    • text
    • dropdown
    • checkbox
    • Message
  • Set an initial value for the input (for text and dropdown)
  • Set possible values (for dropdown only)
  • Specify whether user is allowed to leave the input empty (for text only)

This will prompt the user for input while executing your macro. The above options will result in the following dialog:

Macro screenshot - User Prompts

See how the message and initial value is placed. If you have multiple consecutive user prompts, Onetastic will merge them into a single user dialog. For instance see the following dialog for the Search & Replace macro:

Macro screenshot - User Prompts

Macro screenshot - User Prompts

As you can see 4 Modify clauses are turned into a dialog box with 4 inputs. This also shows different input types: text for "Find what" and "Replace with", dropdown for "Scope", and checkbox for "Match case". You can also see the underlined shortcut keys (like F in Find what), which comes from the & characters right before the corresponding letter. This is standard Windows way of specifying accelerators for labels. Hitting Alt+F will move the cursor to the "Find what" box. Finally, for the first input it is specified that user cannot leave it empty, therefore the OK button is not enabled until user types into it.

Macro Logging

When you run your macro, if it doesn't seem to be doing what you expect it to be doing, there is a way to generate logs from the execution to investigate the cause. To do so, go to the Settings and check Enable Macro Logging in the ribbon and re-run your macro. This will generate a macrolog.txt file under %appdata%Onetastic. You can see what operations took place and what the values of variables and properties were in the log file.

Conclusion

Hopefully this gives you some idea about how to build macros with Onetastic. You can also look at existing macros in the Macro Editor by going to Edit Macros dropdown. You can inspect the macro and try to understand how it works.

Update: A new tutorial about inserting text using a macro is available here.

Comments

Name
Comment
mmo - 2013-05-24
Thanks! you may want to note that somewhere on the download pages. IMHO that's not exactly selfevident, at least not for someone new to Onetastic.
Omer Atay - 2013-05-23
mmo, you need to execute the downloaded file by double clicking on it. That will install the macro.
mmo - 2013-05-23
Where to save downloaded macros to?
I must be missing the obvious, but if I download a macro (from Macroland or from anywhere else), where the heck do I have to save it to? I tried and simply saved it in my usual Download-folder but of course that alone doesn't make it show up in Onetastic's list of available macros. So, I suppose there is a "well-known" directory somewhere where one has to save such macros to so that Onetastic can locate them at startup time and loads them. But the documentation doesn't describe where this "well-known" folder is...
M.
Show more comments (44 more)
namAehT - 2013-05-05
could we get a mod or a floor operation? actually, floor would be more useful since you can use it for more complex things then mod
mxpk123 - 2013-04-27
Is there a way I can apply a custom style to text I've got highlighted with a macro?

I'd like to bind them to keyboard shortcuts and this is the best way I can find would be a macro. But apply styles as a whole rather than having to choose each property would be useful, setting up the macros is too much hassle to do them all.
alex - 2013-04-04
Many thanks. It works!!!
Omer Atay - 2013-04-03
Alex, it sounds like you want to say
<For each="Text">
instead of
<For first="Text">

Does that fix the problem?
Alex - 2013-04-03
Hi Omer,
In my notes, I had to frequently repeat the task of changing the selected text to Courier New with font size 10. To make it working automatically, I wrote the following macro but I found it only works well with the first line and part of my second line of the selection. For example:
A = num2str([1:5;1:5])
B = mat2str([1:5;1:5])
C = str2num('44')

<?xml version="1.0" encoding="utf-16"?>
<Macro name="Codes" category="Content" description="">
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <ModifyProp name="fontName" op="set" value="Courier New" />
    <ModifyProp name="fontSize" op="set" value="10" />
  </For>
</Macro>


I really do not where the problem comes from? Any suggestion?

Alex
SH - 2013-04-01
Hi Omer,
I was looking at creating a TOC macro that would add a TOC at the top of a page, where the TOC entries were the Titles/Names of any subpages.

I was looking for "For each Subpage in CurrentPage", or the name of the parent page in properties, i.e "That has ParentPage equal to CurrentPage"

Is there anyway to accomplish this?
Omer Atay - 2013-03-18
ceejames, you can change the Search & replace macro to search in Current Notebook or All Notebooks instead of Current Page
ceejames - 2013-03-07
Trying to see if this could do a global search and replace, have imported from Evernote and replaced all my apostrophes with &apos; and want to change them back to apostrophes. Would like to be able to do a complete notebook. Is this possible with this add in.
Omer Atay - 2013-03-02
Kari, this worked for me, it will output in the XML format. That is: 2013-02-21T09:08:33.000Z. To get the date in a better format, you need to further process it. For an example expand the comments below and find the one from user named "helt".

Also your macro replaces the "text" property. If you want to append to the end of it try "Add ... to it" from the operation list instead of Set. It will look like:
<ModifyProp name="text" op="add" var="date" />
Kari - 2013-03-01
Hello Omer Atay,
Thanks for very nice program. I tried to create a macro which is here:
<?xml version="1.0" encoding="utf-16"?>
<Macro name="Date" category="Content" description="">
  <For each="Paragraph">
    <That hasProp="selection" op="eq" value="partial" />
    <ModifyVar name="date" op="set" prop="creationTime" />
    <ModifyProp name="text" op="set" var="date" />
  </For>
</Macro>

I tried to write the creation date of piece of text on the page after the text. It did not work quite right. I think that the macro for some reason changed the creation in the XML of the page. Did I do something very wrong or is this a feature in the OneNote? Would it be possible to have the date shown in a standard format?
Kari
Philippe J. Bruno - 2013-02-10
Omer, thanks for your reply. Unfortunately, I already thought of doing the XML search and replace trick, but it appears to me (after conducting some tests) that this workaround only works with OneNote pages that are not too large (hard to give a feeling of what's large as there is no line number or page number in OneNote, but let's say more than 10 screenfulls). In my case, it seems that the XML gets truncated to about half of its real length... With small pages, the workaround works beautifully and I use it often to change the creation date and time of a page to some value not in the drop down list of values.
Omer Atay - 2013-02-09
Philippe, unfortunately this property was missing from the macro processor. I will add this for the next update so that you can set them via a macro. As a workaround what you can do is to get the XML using Settings > Show Page XML, then copy it to notepad and search and replace
<one:Table
with
<one: Table bordersVisible="true"
Then paste the XML back into the dialog you got it from and click OK. This should update all the tables on the page.
Philippe J. Bruno - 2013-02-09
I have a OneNote page that contains lots of tables pasted from a Website. Unfortunately, all the tables have their borders hidden. I tried using Onetastic macros to reveal the borders of all the tables on the page, but there is no such property. I inspected the XML of the page to see and there is a "bordersVisible" property set to "true" when a table has its borders visible. However, even if I import a script trying to change that variable as a Onetastic macro, I get an error when I execute the script. Is there a way to accomplish what I am trying to do?
DL-IND - 2013-01-21
Omer,

Is it possible to provide inserting Date via OneCalendar?
For instance, if the user right-clicks the date in OneCalendar (or, perhaps, simply click the area on the left-hand of the date, which is currently not occupied by any item), a popup menu appears providing 2 menu items, such as:
"Insert Date (Long Format)", and
"Insert Date (Short Format)" .

It will insert Date only (without Time) on the position of pointer of the currently opened page and the format is based on system default.
I think it will be useful for planning something in the future such as next meeting, etc.

Thank you.
DL-IND - 2013-01-21
Omer,
[..you won't be able to create three paragraphs...]
Thanks for the confirmation. I will see the macro you mentioned.
Thank you.
Omer Atay - 2013-01-21
DL-IND, for your macro question, you can currently only edit text for an existing paragraph through macros. So you won't be able to create three paragraphs like that. I guess you can create three separate macros and add them to QAT and do something like Alt+5+Enter+Alt+6+Enter+Alt+7 and even combine them to a single shortcut using AutoHotkey. As for converting the date, expand the comments below and find the one from "helt" for getting the month name. You can't get the day of week though. I don't have any manuals other than what is available on this website. Check the Inserting Text post for some more info.

For translating Onetastic, check the Translate Onetastic link at the bottom of the  website. You will need to contact me by email to get the process started.
DL-IND - 2013-01-20
Omer,
I am trying to find out which file to handle if someone want to translate Onetastic into a certain local language. However, I can not see where to download the file.
Is it not available here?
Thank you.
DL-IND - 2013-01-20
sorry,
The date/time value is inserted as a current-date/time stamp.
thanks
DL-IND - 2013-01-20
Halo, Omer.

1.
I want to insert the following automatically: (without "-----")
-----
Date: Monday, 23 January 2013
Time: 20:45
Topic:
-----
The time format (short) is identical to the system default, but the date format is not, which is :
(short) yyyy-MM-dd
(long) dddd, MMMM dd, yyyy

And I do not want to change the system default.

Can I use Onetastic macro for that purpose? Which part of the macro I should learn ? (sorry. I am rather slow about this programming things)

2.
Do you provide manual of Onetastic (including macro manual) in pdf format ?

Thank you.
.
Wolle - 2012-10-28
ok, I understand, thanks for the info.
Omer Atay - 2012-10-27
Wolle, this is currently not possible. Style property is marked as read-only due to it being somewhat complicated. This can be added in the future but it just won't work right now. As a workaround, you can set the font/color/size etc. properties as you like.
Wolle - 2012-10-27
hi Omer, found your add-in recently and I LOVE IT. Well done, great work.
I have an issue with the macro function. How can I apply one of the predefined styles to a paragraph, i.e. appling Heading1 ("h1") to a paragraph that has the style Heading2 ("h2")?
Using the macro editor, I don't find a parameter 'style' when using the 'Modify' Command.
I would expect the macro to look like
<?xml version="1.0" encoding="utf-16"?>
<Macro name="mod H2" category="helts" description="reformat">
   <For each="Paragraph">
      <IfProp name="style" op="eq" value="h1">
        <ModifyProp name="style" op="set" value="h2" />
      </IfProp>
    </For>
</Macro>

Doesn't work though, even if I modify the xml file directly. Any ideas?
Thanks, w.
helt - 2012-10-05
So heres the updated macro.
<?xml version="1.0" encoding="utf-16"?>
<Macro name="H1-Date" category="helts" description="Adds the current date to the current position for a new diary entry">
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <IfProp name="value" op="eq" value="">
      <ModifyProp name="value" op="set" value="insertAndKill" />
    </IfProp>
  </For>
  <For first="Page">
    <That hasProp="isCurrentlyViewed" op="eq" value="true" />
    <ModifyVar name="currentDate" op="set" prop="lastModifiedTime" />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="insertAndKill" />
    <ModifyProp name="value" op="set" var="currentDate" />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value=".000Z" />
    <ModifyProp name="value" op="set" value="" />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="T" />
    <ModifyProp name="value" op="set" value=" -- " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="-01-" />
    <ModifyProp name="value" op="set" value=" January, " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="-02-" />
    <ModifyProp name="value" op="set" value=" February, " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="-03-" />
    <ModifyProp name="value" op="set" value=" March, " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="-04-" />
    <ModifyProp name="value" op="set" value=" April, " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="-05-" />
    <ModifyProp name="value" op="set" value=" May, " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="-06-" />
    <ModifyProp name="value" op="set" value=" June, " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="-07-" />
    <ModifyProp name="value" op="set" value=" July, " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="-08-" />
    <ModifyProp name="value" op="set" value=" August, " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="-09-" />
    <ModifyProp name="value" op="set" value=" September, " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="-10-" />
    <ModifyProp name="value" op="set" value=" October, " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="-11-" />
    <ModifyProp name="value" op="set" value=" November, " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="-12-" />
    <ModifyProp name="value" op="set" value=" December, " />
  </For>
</Macro>

The date will be printed as "yyyy mmmmm, dd -- hh:mm:ss"

And now there are even more wishes but i think each of them will take quite a lot of time to implement as it would more or less implementing a turing machine :)
- possibility to call macros from within other macros (like "getMonthName(date :string)"
- possibilty to call some onenote functions directly ("API" =D )
helt - 2012-10-04
Omer, Alt+Shift+F, Ctrl+Alt+1 was what i used to do. tbh, in a custom ribbon i placed those two near each other to be able to do it by using touch.

btw. macros that can simulate key strokes would be cool, too :)
THANK YOU for the plain and simple import export possibility. It simply rocks :) When it comes to repetitive stuff, i like the simplicity of a text editor :)
Omer Atay - 2012-10-02
Helt, there is currently no way to add the current date or time through macros. However you can modify the inserted text and remove the things you don't like. The date will print as "2012-10-03T08:24:35.000Z" and you can clear the "T" and the ".000Z" by changing your macro this way:

<?xml version="1.0" encoding="utf-16"?>
<Macro name="add Date as H1" category="helts" description="Add a date">
  <For first="Page">
    <That hasProp="isCurrentlyViewed" op="eq" value="true" />
    <ModifyVar name="currentDate" op="set" prop="lastModifiedTime" />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <IfProp name="value" op="eq" value="">
      <ModifyProp name="value" op="add" var="currentDate" />
      <ModifyProp name="fontSize" op="add" value="12" />
    </IfProp>
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value="T" />
    <ModifyProp name="value" op="set" value=" " />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <That hasProp="value" op="eq" value=".000Z" />
    <ModifyProp name="value" op="set" value="" />
  </For>
</Macro>

This is basically finding the text that has "T" and ".000Z" and replace them with space and empty string to clean it up. You can find more of similar tricks in the "Inserting Text" tutorial I posted.

If all you want to do is to add a heading 1 date, you may want to use the built-in shortcuts:
Alt+Shift+F will add the current date time
Ctrl+Alt+1 will switch to the Heading 1 style
helt - 2012-10-02
COOL! The macro editor is great.
I keep kind of a diary (permanently docked) which is a loooong page with lots of loose notes. these are separated by Headings that contains just Date + Time.

So i have some follow up questions. Is there a possibility to add the current date to the content? Im using Page.lastModifiedDate but this is not really correct. The format of lastModifiedDate  is rather ugly.
Is there a possibility to reformat it (directly or by maybe regexp)?
Instead of making text bold and large, id like to apply "Heading 1" to it.

<?xml version="1.0" encoding="utf-16"?>
<Macro name="add Date as H1" category="helts" description="Add a date">
  <For first="Page">
    <That hasProp="isCurrentlyViewed" op="eq" value="true" />
    <ModifyVar name="currentDate" op="set" prop="lastModifiedTime" />
  </For>
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <IfProp name="value" op="eq" value="">
      <ModifyProp name="value" op="add" var="currentDate" />
      <ModifyProp name="fontSize" op="add" value="12" />
    </IfProp>
  </For>
</Macro>

I really appreciate your macro editor. Its just what onenote needs to satisfy power users ;)
Jan Roelof - 2012-10-02
Thanks Omer - I'll post my questions in the answers forum.
I know about the object model on codeplex, but it was dead more than a year ago already and never got past the notebook hierarchy to the page content. I've come further than that and can now do statements like "currentPage.LastParagraph.Alignment = "right"". My current problem is that I can't get tags to work when updating pages.
Omer Atay - 2012-10-02
Jan, I don't know of any such forum for OneNote development. However I try to answer any questions on the answers forum about development. I think the reason that OneNote development is not much common is that you need to compile code to get anything done. This is unlike other apps where through VBA you can do stuff very quickly. I mentioned this on the first post about Macros here and Macros are my attempt to simplify things so that you can write as quickly as you can do VBA in other apps. There was a similar effort for OneNote 2007 at http://onom.codeplex.com but the requirement to compile code is still there, making it a big barrier for a lot of people.
Jan Roelof - 2012-10-02
Omer, this is a bit off-topic. Your macro utility inspired me to restart a project which I stopped working on a year ago, which is a OneNote Object Model, covering everything from the OneNote root down to CData in T nodes.. The problem I had then and which still appears to exist now is that programming for OneNote is so poorly supported. There is no place that I know of where you can go with your questions. The OneNote answers forum (sorry - community) is for end users and if you ask something in the Office developement forum nobody knows anything about OneNote.
Can you point me to a forum or any other place where I can go with OneNote programming questions and problems?

Thanks!
Jan Roelof
Will - 2012-09-30
GREAT!  I just downloaded and tested.  This is EXCELLENT Omer.  Now I can arrange my to-do items however I want within my notes, and have the order preserved in the tag-summary.  I simply run this macro (below), and then do a tag-summary (sort by date).

<?xml version="1.0" encoding="utf-16"?>
<Macro name="set_tagdate" category="" description="">
  <For each="Paragraph">
    <That hasProp="tagName" op="contains" value="To Do" />
    <ModifyProp name="tagCreationDate" op="set" value="2001-01-01T00:00:00.000Z" />
  </For>
</Macro>

Will do more testing in the days ahead (on my real work stuff -- at home at the moment), and let you know if anything relevant arises.  I'm absolutely STOKED Omer.  You nailed it.  And in general, the importance of your Add-In is not to be underestimated by the OneNote team.  The ability to extend functionality like this is key (IMHO) to OneNote's utility, (and therefore it's acceptance).  
Well done!
Omer Atay - 2012-09-29
Will I just updated the add-in. Go ahead and download it again. You should now see tagName property which you can use in the filter and it should skip the other paragraphs.
Will - 2012-09-29
Any progress on the tag-fix Omer?  (ie so that within any given selection, just the tagged paragraphs can be found and acted upon, eg. date-modified ).   Thanks again for this.
Will - 2012-09-27
Thanks Omer!  Waiting with great anticipation.
Omer Atay - 2012-09-26
I might be able to fix the add-in in a few days. Check back soon and I will let you know here when it is available.
Will - 2012-09-26
Wow, thanks for the quick response Omer!  You mentioned:
>>but it will claim schema error if it encounters a paragraph that
>>doesn't have tags instead of skipping those.
...bummer --  Is there way to get Onetastic to overcome this, so that Onetastic correctly finds all the to-do tagged items in a selected section, and changes their tag creation date?  (Or must I, impatient soul, wait for your new release =]).  The motivation for my request is actually a workaround for a silly issue within Onenote that has really hamstrung the way I work:  Namely (and I corresponded with John Guinn on this -- helpful) in OneNote 2010, the tag-summary is *unable to list tagged items in their original order* as they occurred in their note or section.  And since I intentionally arrange my to-do items into specific groups, and in a specific order that I need, this is a real bummer.  After my careful arrangement of to-do items, the tag-summary insists on re-sorting my to-do items by alphabet, date, etc, etc.

So where does Onetastic fit in?  I found something I'm trying exploit as a workaround.  Namely, that if one chooses to sort their tag summary  *by date*, then the tags are indeed left in their original order of occurrence *if they all occur within a single day*.  Therefore, if I can wholesale change all of my to-do tag-dates to the same day before running a tag summary, then use the sort-by-date option in the my tag-summary, oala', the summary will extract and list all of my to-do items in the order that I arranged within the original note.
Make sense?  Obviously, the *real* solution would be to allow the tag-summary to sort by "original order" -- but I suspect that will be a longer time in coming.  I share all this in hopes that 1) it made sense, and 2) perhaps it will jog an idea of another Onetastic workaround to my desired end, and 3) it will elicit such deep sympathy, that you will crank out a fixed tag-filter as quickly as possible =]. (but seriously, my use of onenote at work has been in a holding pattern because of this specific issue)

What say?
--Will
Omer Atay - 2012-09-26
And when reporting issues please just paste the macro XML from the Export box, which is both easy for you and it can be easily imported back to try it out.
Omer Atay - 2012-09-26
Will, thanks for trying and reporting issues. You found a bug: filtering by tag is not working. In fact there is no such property named "tag" instead there are 5 tag related properties (other than what Macro Editor shows): tagName, tagType, tagSymbol, tagFontColor, tagHighlightColor. It would be accepted if you modified XML manually (that is tagName equals ToDo), but it will claim schema error if it encounters a paragraph that doesn't have tags instead of skipping those. What you can do instead is to have your macro look for selected paragraphs and set their tagCreationDate. Then you can select paragraphs that you care and run the macro. Also note that the time format needs to be in UTC XML time format, that is: 2001-01-01T00:00:00.000Z. Now lets try the following:

<?xml version="1.0" encoding="utf-16"?>
<Macro name="Set Tag Creation Date" category="Tags" description="Sets the creation date of the tag on the selected paragraph">
  <For each="Paragraph">
    <That hasProp="selection" op="not" value="none" />
    <ModifyProp name="tagCreationDate" op="set" value="2001-01-01T00:00:00.000Z" />
  </For>
</Macro>


Hopefuly in a future update I will get filtering by tags working and I also want to add a date/time picker so that you don't have to type the date like this. One more thing to improve here is to give a better error message when macro execution fails. In this case it should say: "tag property not found on Paragraph object".

Thanks again and let me know if you need more help.
Will - 2012-09-26
Looks like a Great tool!  A hand?  I'm trying to change the creation date of "to do" tagged items, but I keep getting the "Macro contains a schema error."  Something obvious I'm doing wrong?
Here's what the macro looks like:
------------------------------------
For each Paragraph in Current Page
        That has property(tag) contains (case insensitive) "To Do"
    Modify property(tagCreationDate) --> Set it to "1/1/2001"
------------------------------------
Thanks in advance!
--Will
Omer Atay - 2012-09-24
Jan the processing of objects are done inside out. So the child objects are processed before parent objects. That way the innermost OE that is selected is the first OE. Because of this you will find that "for last paragraph, that has property(selection) not equal-to none" will not work properly. It will end up considering the parent OE as the last OE that is partially selected, but it is before the selected OE.
Jan Roelof - 2012-09-23
Thanks Omer, the "for first paragraph, that has property(selection) not-equal-to none" trick works, It even works when the paragraph is indented under another paragraph and I don't understand how you do this? The "OE" element dominating the indented and selected "OE" also has the "selected" attribute set. Unless you look at sibling "T" elements to see if one of them has "selected='all'"? Just curious.
Omer Atay - 2012-09-22
Jan, if you mean the selected paragraph by "current paragraph", you can specify it by "for first paragraph, that has property(selection) not-equal-to none". That means the first paragraph that is fully or partially selected. See:

<?xml version="1.0" encoding="utf-16"?>
<Macro name="Add Text" category="Content" description="Adds text at the end of selected paragraph">
  <For first="Paragraph">
    <That hasProp="selection" op="not" value="none" />
    <ModifyProp name="text" op="add" value="Some text to add" />
  </For>
</Macro>


This will add to the end of the paragraph. If you want to add text to the cursor position, you can do something like:

<?xml version="1.0" encoding="utf-16"?>
<Macro name="Add Text at Cursor" category="Content" description="Adds text at the cursor position">
  <For first="Text">
    <That hasProp="selected" op="eq" value="true" />
    <ModifyProp name="value" op="add" value="Some text to add" />
  </For>
</Macro>


I should write up about this as a new tutorial.
Jan Roelof - 2012-09-22
Well Omer, I think you really outdid yourself this time! This macro utility was sorely missing and I am sure will prove extremely useful. I have not yet had a chance to play around with it much, but it appears to be quite powerful.
One question: is it possible to create a macro that applies only to e.g. the current paragraph rather than first, last or each?
And Neil: thanks for your macro! I do a lot of document scanning and until today resizing a multi-page document was a hand job!
Omer Atay - 2012-09-21
Neil, that is very cool! Thanks for sharing your macro. I plan to set up a place where people can submit their macros, and others can review/download etc. I am sure other people will find your macro very useful as well. Hopefully we can create a repository with every possible automatable action available for download.
Neil - 2012-09-21
Wow - thanks for this Omer!  Used it to solve a problem I was having getting all of the pages scanned from my flatbed to have the same width:

<?xml version="1.0" encoding="utf-16"?>
<Macro name="SetImageWidthToFirst" category="Image" description="Sets every image's width to match the first item while maintaining aspect ratio">
  <For first="Image">
    <ModifyVar name="FirstImageWidth" op="set" prop="width" />
  </For>
  <For each="Image">
    <ModifyVar name="NewHeight" op="set" prop="height" />
    <ModifyVar name="ScaleFactor" op="set" var="FirstImageWidth" />
    <ModifyVar name="ScaleFactor" op="div" prop="width" />
    <ModifyVar name="NewHeight" op="mul" var="ScaleFactor" />
    <ModifyProp name="height" op="set" var="NewHeight" />
    <ModifyProp name="width" op="set" var="FirstImageWidth" />
  </For>
</Macro>

Other Posts

  • Macros beyond Current Page and Macroland, a repository for Macros
  • OneNote SkyDrive Sync - Why you shouldn't use other...
  • Onetastic and OneCalendar Now Available in German
  • Onetastic and OneCalendar Now Available in Chinese and Turkish
  • How to Set up Shortcuts for Macros
  • Translate Onetastic into Your Own Language
  • Macro Tutorial - Inserting Text
  • Error Reporting
  • Function macro

FEATURES

  • Macros
  • OneCalendar
  • Image Utilities
  • Custom Styles
  • Favorites/Shortcuts

INFO

  • Blog
  • FAQ
  • Changelog
  • Contact
  • Translate Onetastic
  • Error Reporting
  • Donate

MY ACCOUNT

  • Login

RSS

  • RSS Feed RSS

FROM THE BLOG

  • Macros beyond Current Page and Macroland, a repository for Macros
  • OneNote SkyDrive Sync - Why you shouldn't use other...
  • Onetastic and OneCalendar Now Available in German
  • Onetastic and OneCalendar Now Available in Chinese and Turkish
  • How to Set up Shortcuts for Macros

DISCLAIMER: The opinions and views expressed in this website are those of the author and do not necessarily state or reflect those of Microsoft.