christopher guertin vamc – west palm beach, fl christopher.guertin@va.gov 1
Post on 24-Dec-2015
219 Views
Preview:
TRANSCRIPT
2
Define what a Macro is Tell the differences between VB and
VBA Record a Macro Edit a Recorded Macro Create a Macro Explain when and why we would use
a Macro in Reflections
Objectives
3
Macro (noun) Webster Dictionary a single computer instruction that
stands for a sequence of operations Sometimes referred to as:
Macroinstruction
What is a Macro
4
VB – Visual Basic
Standalone Can be used complied
into an executable and run outside the host
Uses same syntax as VBA
VBA- Visual Basic For Applications
Requires an Application
Reflections Excel Word Access
Is complied and run within inside the host only
Uses same Syntax as VB
VB vs VBA
5
Saves Times Consistent Data Easy to make both minor and major
changes Exportable / Importable Multiple + Easier to use interfaces Allows for User Input Software Already Available
Why use a Macro
6
Automating almost anything Mouse, Keyboard, Options on Menu
Creating Dialog Boxes or User Forms Passing Data Between Applications Error Checking and Handling
What a Macro Can Do
7
Examples: Change Screen Fonts, Color, Size Assign Functions to Keys Allow User Input for Fileman Reports Allow Fileman Reports to be Dynamic Clean up “Dirty Data” Complete Repetitive Tasks Works well with Fileman Transfer Data to/from MS Office Products No Programmer Access Required
Benefits of Macros for Reflections
8
DO NOT put your username or password into a macro to use as an AutoLogin
Code Entered is generally not considered Encrypted
Security
10
Must start with letter May Contain Numbers, Letters May use an Underscore 80 Character Max No Special Characters or Spaces
Example: INPT_WORKLOAD_2011
Naming a Macro
16
Right Click Tool Bar
Setup Toolbars Customize New Button
After Recording – Check – Create Button
Assigning to Button on Toolbar
32
Format() Format(expression[, format[, firstdayofweek[, firstweekofyear]]])
strDate = Format(strDate, "dddd, mmm d yyyy") Wednesday, Aug 3 2011
MyStr = Format(strTime, "hh:mm:ss AMPM") 05:14:03 AM
Format Date / Time
33
Operators Arithmetic
+, -, *, / Comparison
>, < , = Concatenation
&, + Logical
And, Not, Or
Expressions
34
Variables Naming
Must start with letter Can be up to 255 characters Cannot contain a Space but can use
underscore Cannot contain Operators or Special
Characters
Variables
35
Should be declared Procedure
Only for that Procedure Automatically declared Dim strDRUG as String
Private All Procedures in the Module Private strDRUG as String
Public All Procedures in All Modules of Project Public strDRUG as String
Variable Life
40
For – Next For Each – Next Do While – Loop Do – Loop While While – Wend Do Until – Loop Do – Loop Until
Loops
43
Format Transmit WaitForString Ucase Lcase
Able to create your own Allows for only one set of code(refer to
it)
Functions
44
‘ Apostrophe for comment(will not run)
Comment Top: User, Date, Explain Function After Code
Declare Variables at Top TALLman Lettering
Use Error Handler Try to make more universal
Good Habits
45
Create in Test Account if possible Be careful and use checks when user
will be creating orders Validate Data
Good Habits
48
Differentiate Screens Allows users to easily change to
preferred color scheme
Changing the Color of the Screen
51
From a Macro you can Load a User Form-Auto-Populate Fields Then Send User Input back to Original Macro
Code Behind the User Form
56
The routine appears to be done but more actions are preformed in the background
May have a final stop to allow it to be aborted
The routine is run
59
Shawn Toy Created an Amazing Add-In for Excel that will allow text that wraps to be flattened out
http://vaww.infoshare.va.gov/sites/vapharmacyinformatics/WIKI/FileMan/FileMan_TextCapture_Tools.aspx
From .TXT to Excel
62
The header will confirm when it was run and what user input was entered
The data can be copied over to a new sheet or the top part can be deleted to make the headers active
The Final Results
65
Pharmacy ADPAC Email Group Visual Basic Books / References VBA Books Google SharePoint (Future)
More Help
66
SharePoint Sitehttp://vaww.infoshare.va.gov/sites/vapharmacyinformatics/WIKI/
VBA/Home.aspx
Share Design Ideas Integrate Fileman Routines Seamless Data Transfer to MS Office
Products VBA / Macro Education Series
Reflections MS Office
The Future
top related