Sunday, December 31, 2017

How to loop a macro in VBA

Dim I
For I = 1 to 20
your code here
Next I



Goto Instruction

Syntax

GoTo label

Group

Description

Go to the label and continue execution from there. Only labels in the current user defined procedure are accessible.

Example


Sub Main 
X = 2 
Loop: 
X = X* 
If
 X < 100 Then GoTo Loop 
Debug
.Print X ' 256 
End Sub

A little secret "how to become an expert...."


Fully plagiarized from 
Then modified to apply for Diabetes
I'll let you in on a little secret on how to become an expert....
Experts know how to research!
  There's simply just too much knowledge out there for any one person to know it all in a particular subject.
 Personally, I would hire someone who could research extremely well over a person with a high IQ any day of the week! 
I don't claim to know all the answers, but 9 times out of 10 I will be able to come up with some sort of answer for you,
 That is extremely valuable in today's marketplace. 
 So take some time to acquaint yourself with a great friend of mine: Google!
Google by far is the best search engine I have used over the years in terms of getting me to articles and resources that answer my questions. 
 But there is a strategy that I have developed when it comes to searching via Google I would like to share with you.

Before you begin typing in your query,
 try to determine the keywords that may trigger more accurate results.
  I always start my searches by using Google Books then Google Scholar
 this will make it more reliable and you will not get fluff from the internet which say eat "Gurmar " from  Santhals and cure Diabetes.
The next word (or phrase) I type in, is the broadest word I can think of that would encompass my question.  Some examples of my second word or phrase could be:
  • Diabetes
  • Type 2
  • Insulin
  • Lantus
  • Dosage
  • Adjusting
 you can get  much useful information just from  reading the  results summary even before going in and  opening the particular book.
such as for the above  query  I got  this info from  1 page 
 "Insulin Glargine (Lantus) Subcut (Adults and Children 6 yr): Type 1 diabetes (insulin naıve)—1/3 of the total daily insulin dose given once daily, then adjust on the basis of patient's needs (remainder of insulin dose should be given as a short-acting insulin) (usual starting total daily insulin dose 0.2–0.4 units/kg); Type 2 diabetes (insulin naıve)—0.2"

Davis's Canadian Drug Guide for Nurses - Page 695

When transferring from basal insulin (Lantus, NPH) in type 1 0r 2 DM, change 0n a than NPHinsulin. PEDS - Diabetes: maintenance: total insulin 0.5–1 unit/kg/d SC, but doses vary. Generally, 50–70% of insulin requirements are provided by rapid-acting insulin and the remainder from intermediate- or long-acting insulin. Age 6–15 yo (Lantus): Start 10 units SC daily (same time everyday) in insulin naive patients, adjust to the usual dose of 2–100 units/d.

Pharmacopoeia 2009 - Page 130

Adjust insulin dosing to achieve glycemic control. See table “diabetes ... ADULTS – Type 2DM: Start 15 to 30 mg PO daily, may adjust dose after 3 months to max 45 mg/day. ... (Novolin N, Humulin N, Lantus, Levemir) LK ♀B/C + $$$$ ADULTS – Doses vary, but typically total insulin 0.3 to 0.5 unit/kg/day SC in divided doses (Type 1), and 1 to 1.5 unit/kg/day SC in divided doses (Type 2)
In head to head comparisons with NPH insulinglargine insulin had a lower incidence of nocturnal hypoglycemia in both type-1 and type-2 diabetics than NPH (31 vs. ... or 0.15 units/kg at same time daily On once daily insulin: give total daily dose at same time daily On twice daily or multiple daily doses: give 2/3 total daily dose at same time daily Suggested titration schedule Adjust dose weekly to achieve fasting glucose <100 mg/dl FBG Increaseglargine dose (units/ day) 100–120
PEDS — Diabetes, age older than 4 yo (Apidra), older than 3 yo (Humalog) or older than 2 yo (NovoLog): Doses vary, but typically total insulin maintenance dose 0.5 to 1 unit/kg/day SC in divided doses. Generally, 50 to 70% of insulin requirements are ... When transferring from twice-daily NPH, the initial Lantus dose should be reduced by about 20% from the previous total daily NPH dose, then adjust dose based on patient response. Levemir, Type 2 DM: Start 10 units or 0.1 to 0.2 
The bedtime insulin injection is the most difficult dose to adjust. Although we do not eat during the night, our bodies need a continuous low level of insulin to prevent the liver releasing glucose freely into the bloodstream. The most common bedtime insulin with multiple injection treatment used to be intermediate-acting insulin of NPH typeInsulin with longer effect (Lantus or Levemir) is now used widely instead

Self blood-glucose monitoring during insulin therapy is crucial because patients will need to adjust their dose to avoid hypoglycemia and to adequately control hyperglycemia. ... Insulin. Therapy. for. Type. 2. Diabetes A recent Cochrane review has summarized the evidence of 20 randomized trials related to insulin therapy in type 2 diabetes (40). The following conclusions can be made from this review: • Slightly better glucose control and reduced weight gain occur if oral metformin, ..

 First, try with ALL books, then filter

Knowing the terminology can save you tons of time while searching 
 I have had scenarios where I search Google for the proper name of a feature before ,I perform my original search.

Don't Be That Guy! I can't begin to count how many times I've seen a question asked in a forum and if the person would have taken 5 seconds to do a quick online search they would have found at least 10 different articles providing them with a step by step solution.
Step 2: Ask A Friend Or Peer
Step 3: Post In A Forum
Step 4: Buy A Reference Book
Now Go Ask Your Question 

Well, there you have it,
 you now know all my tips and tricks 
to solving any problem you may come across. 
When you get really efficient,
 you will be able to answer your patient' questions within minutes and take credit for it. 
Having the ability to research and find solutions will get you well on your way to being known as a guru 

 I really hope this resource is useful to you and please leave any feedback or tips of your own in the comments section below. 
Good luck!




Help manuals written by experts which are useful for other experts only


All the following expressions are like Greek and Latin to me.

Now I understand how patients must be feeling when I'm trying to explain to them about medical terminology


condexpr definition

An expression that returns a numeric result. If the result is zero then the conditional is False. If the result is non-zero then the conditional is True.
0 'false 
-1 'true 
X > 20 'true if X is greater than 20 
S$ = "hello" 'true if S$ equals "hello"

Wait Instruction changed from milliseconds to seconds

Changed from milliseconds to seconds wonderful progress from old version to the new version?

Wait Instruction

Syntax

Wait Delay

Group

Description

Wait for Delay seconds.

Examples

Sub Main 
Wait 5 ' wait for 5 seconds 
End
 Sub
Sub Main 
Wait 0.5 ' wait for ½ second 
End
 Sub

Intelligent Content Development with Topic-based Authoring

I am looking for a cheap or free Intelligent Content Development with Topic-based Authoring

Topic-based authoring is a modular content creation approach that supports XML content reuse, content management, and makes the dynamic assembly of personalized information possible.
Save time and money by creating intelligent, topic-based content that can be customized and used to create different variations of outputs for different audiences and users, such as:
  • Beginner and Advanced Guides
  • Policy and Procedure Manuals based on city, region or country
  • Employee Handbooks for every level within the organization
  • Admin and Programmer Guides
  • Getting Started and Quick Start Guides
  • And much more

SendSystemKeys is not showing up in green

When I use this command in Advanced Scripting in the editing window it is not showing up in green color unlike the SendKeys command


Sends keystrokes to the Windows operating system. Use this command only when SendKeys fails to perform. You can use SendSystemKeys to send key combinations such as {Ctrl+Esc}, {Alt+Esc}, and {Alt+Tab}.

Syntax

SendSystemKeys "keystroke text"
ArgumentDescription
keystroke textThe keystrokes to be sent to the Windows operating system. Enclose the names of nonprinting keys in braces ({ }).

Example

This instruction executes the "Switch to Next Window" command.
SendSystemKeys "{Alt+Esc}"

Notes

  • Do not include spaces between the names of simultaneously-pressed keys, such as Alt+Tab.
  • Any modifier keys (SHIFT, CTRL, ALT) pressed while the SendSystemKeys command executes affect the command action.
  • The SendSystemKeys command sends keystrokes more slowly than the SendKeys command. Also, if the system responds slowly long strings can overflow the system keyboard buffer.

WaitForWindow a useful command which has been abandoned by Nuance

Dragon scripting language extensions quick reference

I have been finding difficulties in running my script using Dragon NaturallySpeaking 14 and I would have found this to be very useful

WaitForWindow

The WaitForWindow command suspends execution of the script until a desired window appears in the foreground.

Note

This command works only for legacy Dragon version 5 commands that have been imported into version 8. It will not work in commands that you create using the MyCommands editor.

Syntax

WaitForWindow caption [, windowClass [, timeout ] ]
ArgumentDescription
captionA text string to match against the window caption. The string may (and often will) include the asterisk (*) character as a wild-card to match against variable parts of the window caption. If parts of the actual window caption are guaranteed to be unpredictable, you MUST use an * wild-card to get a successful match.

The caption may also be an empty string "," to indicate that the caption does not matter.
windowClassA text string which, when not empty (""), must exactly match (case-sensitive) the window class name of the window you are looking for. The window class name is usually obtainable only through programmer utilities like "Spy".
timeoutThe length of time, in milliseconds, to wait for the window to appear. If no matching window appears by then, a timeout error is displayed, and the script stops without executing any subsequent commands following WaitForWindow. If not specified, defaults to 10 seconds.

Examples

In the following example the * in the caption is an instruction to ignore "Document1".
AppBringUp "(correct path here)winword.exe"
WaitForWindow "*Microsoft Word"
SendKeys "this text will appear in the Word document, not the splash screen"
The following example waits for Word's main window by class name.
AppBringUp "(correct path here)winword.exe"
WaitForWindow "," "OpusApp"
SendKeys "this text will appear in the Word document, not the splash screen"
The following example starts Microsoft Outlook, waits as long as 30 seconds in case the network is slow, and then types Alt+n to create a new E-mail.
AppBringUp "(correct path)outlook.exe"
WaitForWindow "*Microsoft Outlook", "," 30000
SendSyste
The Dragon scripting language extensions provide a set of tools for creating Dragon voice commands.
Dragon Advanced Scripting lets you use programming languages such as Microsoft® VBA to program commands that can perform virtually any function on the computer with voice commands.
The Dragon scripting commands, listed below, are the commands that you can specify in the Command parameter of the Add method.
See the topics guidelines for writing scripts and voice command list variables for more information on using the following:

Dragon scripting language extensions

A

B

C

D

G

H

M

P

R

S

T

W

Reference

You want to call a voice command?

 if you want to call the command my voice command then you can call it from another advanced script as follows:
Sub Main
HeardWord "my", "voice", "command"
End Sub
Another example, say you want to automatically write down [name](link) assuming that you have link as the most recent clipboard and name as the second most recent clipboard (using Ditto to manage the clipboard history), you can use the command:
Sub Main
    originalClipboard = Clipboard
    SendKeys " ["
    HeardWord "paste", "two"
    Wait(1)
    Clipboard("](" & originalClipboard & ")")
    SendKeys "^v"
    Wait(1)
    Clipboard(originalClipboard)
End Sub
shareimprove this answer

Dragon Sample Commands Commentary

Dragon Sample Commands Commentary

This is a very old article about Advanced Scripting in Dragon NaturallySpeaking but I found some of the points in it quite interesting.

 NOTE: This is draft material, further updates will be posted late-February 2007. Nuance includes several advanced sample commands with Dragon NaturallySpeaking®. These are normally installed in the directory: C:\Documents and Settings\All Users\Application Data \Nuance\NaturallySpeaking9\Data\Enx\samplecommands Upon installation, a shortcut to this directory is placed in the Dragon NaturallySpeaking 9 program group so that you can go to Start, All Programs, Dragon NaturallySpeaking 9.0, and then MyCommands Samples. The commands are in XML format. There is a readme.txt file and an associated Word template for one of the command sets. Seven sets of commands are included. When imported, the commands go into the “Dragon Sample” command group, so that once finished with the commands, they can be easily deleted from your system from the Manage tab. Like most of the samples in this book, these are not intended to be used as-is, but are intended to be modified as needed. These commands focus on the use of the features introduced in Dragon NaturallySpeaking® 8 providing “Structured States” for command recognition. This is an expansion of the concepts of having application-specific commands and window-specific commands. One of the samples provided, the Endoscopic Biopsy sample, does not deal directly with Structured States. It provides an example of how to do similar tasks without using states, using only the new “PromptValue” method. The following commentary presumes that you have imported these commands into a Release 9 Dragon NaturallySpeaking®. This is done by opening the Command Browser, going to the Manage tab, selecting Import, navigating to the above directory, changing the “Files of Type” to show XML files, and then importing the command sets, one at a time. All of these illustrate relatively advanced concepts and techniques for creating commands. Following is additional commentary on these commands. It is anticipated that the reader will read the readme.txt file and the comments within the text of these commands. The order in which these commands are discussed is different from that presented in the readme.txt file associated with these commands, instead starting with the simplest command and progressing through the most complex. When reviewing these commands, use the Dragon option to have DragonBar at the top of your screen even if you normally have it in Tray Icon or some other mode. Otherwise you will not see some of the command behavior. These commands are not intended as illustrations for casual users. They are illustrations of command technique for persons willing and able to design moderately-complex sets of commands for particular applications. The commands themselves use a wider variety of VisualBasic and VisualBasic for Applications features than the prior examples. SetStateSample The text of this command is found by going to the Script tab of the Command Browser, setting the Current Command Grammar to “Dragon NaturallySpeaking – DragonPad,” highlighting the “sample set state” command, and selecting either Edit or New Copy. This is the simplest of the command sets dealing with states, and illustrates the basic concept. Understand it before moving on to more complex groups of commands. The key concept is simple: set a “State” and then the commands defined as being recognized in that “State” should be recognized. This is an artificial command built only to show the concept. Don’t look for any hidden meaning in what this command does. After giving the command “sample set state” then give one of the directly-related commands defined in the command. These commands are: Good afternoon Good day Good morning Good evening After doing so and getting the red font response message, then give a global command such as “show dictation box.” Seeing that command work normally should remind you that the “State” does not exclude global commands. Dictate plain text and you will note that being in a “State” does not exclude dictation. If you attempt an application-specific command, it should also work. By itself, the SetState adds commands that are defined in the appropriate State…in this case, the “RedFontParrot” State. The State itself is invisible. The “goodbye” command references the GetState function in a simple fashion to determine whether the “RedFontParrot” State is active or not. Near the end of the “goodbye” command the ShowMessage method shows how to place text on the DragonBar. This method is useful in applications where simple instruction or prompting is needed and the DragonBar is known to be present. Such messages do not show if the DragonBar is not present as when the Tray Icon mode is selected. (As an exercise for the reader, modify one of the following commands to display the State in the DragonBar using ShowMessage as the State changes. It might assist you in following the command logic.) After giving the “goodbye” command, try the “good afternoon” command again. It should not be recognized as a command as the State is no longer the RedFontParrot State. Grocery List Sample – DragonPad There is a set of 4 commands comprising the GroceryListSample_DragonPad. In addition to the techniques introduced in the “sample set state” command it introduces the PromptValue function. The commands are: prepare grocery list which must be the first command given The commands: are all almost the same. Each of these recognizes a set of food names plus the key phrases “what’s available” or “next” as commands. There are slight differences because <…> is set up to be the first part of the grocery list, <…> the second part, and <…> the last part. In the Manage and Script displays, notice the Current Structured State box for selecting the State for display. Within the Browse display, there is no evidence of Structured States. In the Browse display, the structured state commands appear, possibly leading to confusion about valid commands within particular applications. That is, a command appearing in the Browse display might be a valid command only within a specific State within that application. “Prepare grocery list” is the initial command – consider it to be the opening of a form. It progresses through the glProduce State, then glMeat, then glDairy before returning to the null (“”) State. By controlling the State, only one group of food items is available at a time to be recognized as commands. At the start, when the State has not been defined and is implicitly null (“”), then the “prepare grocery list” is the only command out of this set recognized. Once this command is entered, it soon changes the State to “glProduce.” That ADDS the commands to those available to be recognized. Note that other DragonPad and global commands are available, as is general dictation. This has only ADDED to the list of recognized commands. That is, while in the state, you can dictate “steak and eggs” and it will be recognized and added to the list as dictation. Remember this is only a sample of a technique! If command mode is set, then dictation will not be active and the only commands available may be those in a specific state. That is appropriate in many applications where a single field has few values. But the and commands are NOT recognized as commands. If you dictate any command from those lists, they will be recognized as text. There are several sets of code deserving close attention in the “prepare grocery list” command. These include a set of code for formatting within DragonPad, WordPad, or other RTF editors, error handling using the On Error statement, the ShowMessage code for presenting text in the DragonBar, and the PromptValue code for presenting a prompt with a limited response set. The statement: ExecuteScript “SetCharFormat “bold=1,underline=1””,1 is one way to force font bold and underlined. It works within DragonPad, WordPad, or other “RichEdit” controls regardless of the current state of the font. In theory the “,1” allows the script to finish. However, sometimes such scripts do not actually complete before the next line of the command is executed. The “SetCharFormat” is part of the Legacy scripting and is not documented in the manual or the help files for Dragon NaturallySpeaking® 9. It is documented in the manuals for Dragon NaturallySpeaking® 5 and earlier releases. While it may require a wait state, it is a handy way of controlling formatting in applications like DragonPad and WordPad. In Word or WordPerfect there are much better means of controlling format. In testing this command, several times I observed headings in mixed formats, as if the bold and underline was applied while the next command was processed. For example, the heading: MEAT: was seen. To avoid such problems when using this technique, add a short Wait statement after the ExecuteScript command. The SendKeys “^e”,True is to center the heading. “Ctrl+e” are the keystrokes to center a line. SendKeys “{Enter}^1{Enter}”,True left-justifies the text. “Ctrl+1” is the left-justify keystroke sequence. If interested in performance, the next two Wait statements could be eliminated by combining the statements: SendKeys “^e”, True SendKeys “GROCERY LIST”, True Wait .2 SendKeys “{Enter}^1{Enter}”, True Wait .2 SendKeys “PRODUCE:{Enter}”, True into one SendKeys statement. SendKeys “^eGROCERY LIST{Enter}^1{Enter}PRODUCE:{Enter}” The next ExecuteScript command sets the format back to normal. The On Error Resume Next illustrates one method of error handling. While it might seem that the next statement could never fail, Dragon NaturallySpeaking® generates an error if it finds no commands in State named in the SetState statement. The SetState = “glproduce” sets the state. The CheckErr function is called to determine if there is an error. Within the CheckErr functions, provision is made to display an error. For longer commands where CheckErr might be called multiple times, the “CallersLine(0)” function might be added so that you could get the line number of the CheckErr statement. Next, the long statement: EngineControl.DragonBar.ShowMessage 0, _ “Say “”What’s available”” to see the list of available items” puts the string into the DragonBar. You may see a truncated version of this message on your DragonBar depending upon your system settings. The ShowMessage function is handy for giving a user hints of what are acceptable responses, displaying error conditions, limitations, etc. The effective length of the text that is actually seen in the DragonBar is dependent on system settings including fonts so should be kept short. Some of the sample messages are too long to fit on the DragonBar. At this point, the “prepare grocery list” command is finished but the task is not complete. The commands in are now recognized. Edit that script to view the complete text of the command. What may not be obvious is that the array Values is used to define the commands that will now be recognized. These do not have to be commands in the ! They can be global commands or they can be application-specific commands. The commands named in the array Values, which is referenced in the statement: Item = EngineControl.PromptValue(Values(), “Available Produce” Will be available to be recognized. It appears that Dragon NaturallySpeaking® may give some priority at this point to the commands in the PromptValue array, but documentation is murky on this point. You may test this by setting one of the Values to “” instead of the vegetable name. Save the command, then try dictating the vegetable name that you effectively deleted. If you are in command mode, it won’t get recognized. If in dictation mode, the word you say may still be recognized as dictation. GroceryList Sample – WordPad This set of sample commands uses the same concepts and coding structures as the DragonPad examples. TGV Restaurant Sample This sample shows how Text and Graphics commands can be blended together with Advanced Scripting commands. It also illustrates how exactly the same command can be set up to present different values in different states. To start this sample, say “Chinese Menu”, “Japanese Menu”, or “Sushi Menu” (do not follow the instructions in the readme.txt file). Where the prompt says “…Say ‘item number’ and a number to order by number” ignore this and just say “item” followed by a number as in “item 3”. It uses the same SetState, GetState, and EngineControl.DragonBar.ShowMessage features that the other commands use. For practice changing commands, as an exercise for the reader, modify the commands to conform to the instructions provided. This requires at least three changes to command names. Colon Cancer Checklist This command operates in Microsoft Word. If not using Word-2003, follow the instructions for changing references before attempting the command. Before looking at the scripts, use the command first in Normal Mode, then switch to Command Mode and execute the same script. After giving the “colon cancer checklist” command, give the command “choose from list” to see the full impact of this command. Then follow the prompts. When in Normal Mode you should notice that you may continue to dictate free text into these fields, or else dictate what is given in the prompts. When in Command Mode the choices are much more restricted. Like the prior examples, this uses SetState, GetState, and PromptValue. No new Dragon concepts are presented, but within this command are examples of how to use some Word constructs along with Dragon. Endoscopic Biopsy The complete name of this command, “ endoscopic biopsy gross template” is rather long. Practice changing command names by giving this command a shorter name. This sample command illustrates how one command can be used to completely fill out a substantial report. To complete it by voice requires that one be in Normal Mode to allow free dictation into the last field. Unlike most of the other sample commands, it does not use the SetState or GetState to modify the available commands. The “commands” that are used to generate the text are actually prompt values in this example. This illustrates a concept that may have a wide range of uses. These prompt values essentially have a written and a spoken form. The “written form” is what is returned as the result of the EngineControl.PromptValue. While this example displays the “written form” one can utilize that value to do other actions within the script. This example illustrates the use of a null value (empty string) to form a separator. Notice how the prompts have a line after the “next” and “normal” entries. That line is a direct result of the setting of Values(3) to “”. To further illustrate this, change the line (arbitrarily chosen): Values(7)="brown\brown" to: Values(7)="" And repeat the commands. Another horizontal separator within the prompts for color will be seen. The prompt values need not be coded directly in the code as illustrated. They may be read from a file, obtained from a database, or constructed from Outlook data. Sample Injury Report The Sample Injury report is an example of how to use Dragon NaturallySpeaking® within a Word Form. It hints at mechanisms to use Dragon NaturallySpeaking® interfaces within other Dragon NaturallySpeaking® macros. The entire macro set for this example is several pages long. For those not familiar with Word forms, there is processing that may not make sense. But for those who use forms, there are several good ideas embedded in this sample. Please refer to the macro set as delivered, as there are several comments not repeated. The Word macros are several pages long. They illustrate how one can introduce commands specific to a field within the context of a Word form. A link to an annotation of the Word macro is posted at the web site: http://www.pcspeak.com/books/ It is advanced material, much more advanced than the other material discussed in this chapter. It is suitable for programmers, persons who have implemented Word Forms, and others with a strong interest in automating data entry.