+ All Categories
Home > Documents > Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL [email protected]...

Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL [email protected]...

Date post: 25-Dec-2015
Category:
Upload: judith-roberts
View: 218 times
Download: 0 times
Share this document with a friend
Popular Tags:
63
Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL [email protected] 20 th /June 2012
Transcript
Page 1: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

Macros For ReflectionsChristopher GuertinVAMC – West Palm Beach, [email protected]

20th /June 2012

Page 2: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Objectives• Define what a Macro is• Tell the differences between VB and VBA• Be able to Create/Record/Edit a Macro• Be able to Import/Export a Macro• Explain when and why we would use a Macro in

Reflections• Understand basic code• Know where to go for more info/help

2

Page 3: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

What is a Macro?• Macro (noun) Webster Dictionary• a single computer instruction that stands for a

sequence of operations • Sometimes referred to as: Macroinstruction

3

Page 4: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

VB vs VBAVB – 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 VB4

Page 5: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Why use a Macro?• 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

5

Page 6: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

What a Macro Can Do?• Automating almost anything• Run complex data/code• Manipulate data into more useable form• Passing Data Between Applications• Error Checking and Handling

6

Page 7: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Benefits of Macros for Reflections

• Easy to use and share• Change Screen Fonts, Color, Size• Assign Functions to Buttons, Keys, Mouse, Events• Allow User Input for Fileman Reports• Allow Fileman Reports to be Dynamic• Clean up “Dirty Data”• Complete Repetitive Tasks• Transfer Data to/from MS Office Products• No Programmer Access Required

7

Page 8: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Security• DO NOT put your username or password into a

macro to use as an AutoLogin• Code Entered is generally not considered Encrypted

8

Page 9: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Getting Started

9

Page 10: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Sample Reflections Screen

10

Page 11: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Where to find

11

Enable Macros in Reflections

•If the Macro Menu is not listed please follow step in word document

Page 12: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Naming a Macro• Must start with letter• May Contain Numbers, Letters• May use an Underscore• 80 Character Max• No Special Characters or Spaces

• Example: INPT_WORKLOAD_2011

12

Page 13: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

How to Record• Macro Start Recording

• Stop, Pause, Annotate

• Can Edit, Create button, Map to key

13

Page 14: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

How to Edit Macro• Macro Macros Edit

14

Page 15: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Creating Macro• Macro Macros• Type in name under Macro Name:

15

Page 16: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

• Open the saved Vista Reflections session

• There are two ways to run the macro:

1. By pressing the newly created button for macro

2. Alternative way is run macro from the Macro menu – Select Macro menu on the main

Vista screen– Select Macros submenu to open a

Macros screen– On Macros tab select the desired

macro and press Run button

• The macro will start running and may prompt user for input

Run Macro

Page 17: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Stopping a Macro• Macro Stop Macro• Ctrl+Break• Create a Button

17

Page 18: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Import Macro• Select Macro menu on the

main Vista screen• Select Macros… submenu

to open the Macros screen• On the Macros screen

select Macro File tab• Press Browse… button to

open Select a Macro File window

18

Page 19: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Import Macro (cont…)• On the Select a Macro

File screen select the desired macro (.rma file)

• Click OK button• Macro name will appear

in the Macro file name field on the Macros screen

• Press Import button to import macro

19

Page 20: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

• Macro Visual Basic Editor (Alt+F11)

• In Visual Basic Editor– File Import File– Select .frm file– When highlighted click Open– Make sure the .frm and .frx are

in the same folder

Importing Forms

Page 21: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

• In Project• Click + next to Form• The form you imported

should now display• Double click on the form

you added and it will appear

Importing Forms(cont.)

Page 22: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

• Macro Visual Basic Editor (Alt+F11)

• Tools References

• Check Box– Checked Add– UNcheck Remove

• Click OK

Adding / Removing Object Libraries

22

Page 23: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Using Macros

23

Page 24: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Assigning Macro to Key• Setup Keyboard Map

24

Page 25: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Assigning Macro to Mouse Button

• Setup Mouse Map

25

Page 26: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Assigning to Button on Toolbar

• Right Click Tool Bar

• Setup Toolbars Customize New Button

• After Recording – Check – Create Button

26

Page 27: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Customizing Buttons

27

Page 28: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

• Setup Events• Highlight Event Requested

– Click Properties to View/Edit– Or New to Create One

Event

Page 29: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

• Event Type:• Enabled• Text• Run this Event• Action

– Macro– Visual Basic

Event(cont.)

Page 30: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Save Vista Reflections Session

• Select File menu on the main Vista Reflections screen

• Select Save As… submenu to open the Save Settings screen

• On the Save Settings screen select the desired directory to save the session in (you will not be able to save the session in the default directory)

• Type the new file name for the session and press Save button (make sure the file extension is .r2w)

30

Page 31: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

User Input

31

Page 32: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

User Input• Wait for Input into Reflections

– Message Box to Help

• Input Box• User Form

32

Page 33: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Message Box

33

Page 34: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Input Box

34

Page 35: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

User Input - form• Many Input boxes can be used or one user form• Default Values may be set

35

Page 36: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

User Form• Could be a course

all by itself• Many Options

– Label– Text Box– Combo Box– List Box

36

Page 37: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

User Form - WYSIWYG

37

• What You See Is What You Get

Page 38: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

User Form – How the User Sees It

38

Page 39: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Examples

39

Page 40: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

• Create Macro Change Column Size

40

Switch Column Size

Page 41: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Screen Capture to Text FileLogging On/Off

41

Page 42: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Prescription Fileman• Easy to Use Interface• Fileman Access Required• No Need to Know Fileman• Allow Direct to Excel • 2 Drugs• Drug + Allergy• Customizable output

42

Page 43: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Prescription Converter• Can Use Fileman to get data• Allows Rxs to be converted one at a time• Automate Complex Process• Saves Time Money• Offers Consistency• Can Send/Receive Data Directly from Excel

43

Page 44: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

More Examples

• SharePoint• http://vaww.infoshare.va.gov/

sites/vapharmacyinformatics/WIKI/VBA/Home.aspx

44

Page 45: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Basic Code

45

Page 46: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Date Converter• Converts Date to Format Useable by VISTA

46

Page 47: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Format Date / Time• 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

47

Page 48: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Expressions• Operators

– Arithmetic• +, -, *, /

– Comparison• >, < , =

– Concatenation• &, +

– Logical• And, Not, Or

48

Page 49: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Variables• 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

49

Page 50: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Variable Life• 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

50

Page 51: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

VB Codes

51

Page 52: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Ascii Codes

52

Page 53: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Message Box Code Values

53

Page 54: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Functions• Format• Transmit• WaitForString• Ucase• Lcase

• Able to create your own– Allows for only one set of code(refer to it)

54

Page 55: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

More Info

55

Page 56: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Good Habits• 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

56

Page 57: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Good Habits• Create in Test Account if possible• Be careful and use checks when user will be creating

orders• Validate Data

57

Page 58: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Help File• Can be useful to learn Syntax and Concepts

58

Page 59: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Help File

59

Methods Properties Events

Page 60: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

More Help• Pharmacy ADPAC Email Group• Attachmate Guide• Visual Basic Books / References• VBA Books• Google • SharePoint

60

Page 61: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

The Present/Future• SharePoint Site

http://vaww.infoshare.va.gov/sites/vapharmacyinformatics/WIKI/VBA/Home.aspx

• Share Design Ideas• Integrate Fileman Routines• Macro Classes• Seamless Data Transfer to MS Office Products• VBA / Macro Education Series

– Reflections– MS Office

61

Page 62: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

VBA – Adding to MS Office Products

• Office Button Options Popular – Show Developer Tab in the Ribbon

62

Page 63: Macros For Reflections Christopher Guertin VAMC – West Palm Beach, FL Christopher.Guertin@VA.GOV 20 th /June 2012.

VETERANS HEALTH ADMINISTRATION

Questions

63


Recommended