expedienceblog

Turning Code Off and On

 

In a previous post we wrote a ‘SpecialPaste’ macro to paste content from the clipboard into a numbered questionnaire and select and indent the content after it is pasted:
This macro indents the pasted content just once, to align with the number of the question.  But I may want to align the content with the text of the question like this:
Sample RFP with Content Pasted and Selected
To do this manually I would just click the indent button twice.  I would do a similar thing in the macro:
Selection.Paragraphs.Indent
Selection.Paragraphs.Indent
Here is the new macro:
But I don’t always want to indent twice.  Sometimes I want to indent once and sometimes not at all.

We could write 3 different macros with a different indent applied in each one.  Or we could go into the code and turn ‘Indent’ lines off and on as we need.

To do this we use the same technique we use to create a comment.  A single quote in front of a line of code turns it into a comment and therefore ‘Off’ as code.

Here is our macro with one of the lines turned off:
Special Paste Macro with one of the Indent commands turned off.
The first ‘Indent’ line of code is now green because we have turned it into a comment.  To turn it back on we simply remove the single quote from the beginning of the line.
Similarly we could turn off the line of code that inserts a paragraph:
Special Paste Macro with Insert Paragraph command turned off.
We can add or apply additional formatting to the macro, such as setting it to bold:
Code to turn font bold is turned on.
And turn it ‘off’ when we don’t want to use it:
Code to make font bold is turned off.
In future posts we will make use of this technique for when sharing code samples with optional code that you can use by removing the single quote.

 

 
Loading a Global Template
Normal or Not? Choosing the best Style Strategy

Related Posts

Comments

 
No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Guest
Saturday, 21 October 2017

Search Our Blog

Schedule a Custom Demo

Explore the versatility and simplicity of Expedience Software.

Schedule Demo

Go to top