Using VBScript For Perfecting Statistical Report

Similar documents
ODS/RTF Pagination Revisit

The Item_Master_addin.xlam is an Excel add-in file used to provide additional features to assist during plan development.

UMHS Financial Systems Workspace & Smart View Templates

Manipulate Microsoft Office Word

Office 365: The Basics Reference Guide for End Users

Documentation. nfront AD Disabler. Version Never worry about dormant accounts again nfront Security. All Rights Reserved.

This is the preferred method when combining documents that are finished and not expected to change.

Working with SQL SERVER EXPRESS

Information Technology (IT) Paper-I Theory 40 Practical - 60

F9 V5 Installation for Citrix Server

A Comprehensive Look at Foxtrot s Action Library

User Environment Variables in App-V 5.0 with SP1, SP2 and SP2 Hotfix 4

Getting Started with Microsoft Office 2013

OPTIS Labs Tutorials 2013

MAILMERGE WORD MESSAGES

1) Identify the recording mode, by which you can record the non-standard object in QTP

Welcome to the SIGGRAPH online networking tool!

Installing. Download the O365 suite including OneDrive for Business: 1. Open the Google Play Store on your Android device

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS

Excel window. This will open the Tools menu. Select. from this list, Figure 3. This will launch a window that

Discovering Computers & Microsoft Office Office 2010 and Windows 7: Essential Concepts and Skills

Karlen Communications

The Studio HST Server object is installed automatically when installing Studio version SP4 or newer.

Manual Calculation Definition Excel 2010 Vba Set

outlook-vba #outlookvba

Manual Vba Access 2010 Recordset Find

BrainyBetty.Com presents: Mail merge I: Use mail merge for mass mailings

Microsoft Word 2011 Tutorial

KEYWORDS DDE GETOBJECT PATHNAME CLASS VB EDITOR WITHEVENTS HMI 1.0 TYPE LIBRARY HMI.TAG

Making an RTF file Out of a Text File, With SAS Paper CC13

Microsoft PowerPoint Illustrated. Unit C: Inserting Objects into a Presentation

Manual Vba Access 2010 Recordset Findfirst

1 MAPLE EXCEL MACRO TECH NOTE JOEL HYING

We will start by reviewing some interface features, then we will explore Mail Merge.

EG 4.1. PC-SAS users. for. I C T EG 4.1 for PC-SAS Users. Thursday - May 7 th, 2009

Access/SAS application for verification and correction: corporate tax returns

WORKFLOW BUILDER TM FOR MICROSOFT ACCESS

GNS 312 (DIGITAL SKILL ACQUISITION) MODULE 3 OFFICE APPLICATIONS

Creating an Adobe Connect Presentation: Using Your Personal Computer to Record and Publish

E3DViewer Instruction

SAS Tricks and Techniques From the SNUG Committee. Bhupendra Pant University of Western Sydney College

Online Access: Login to The Media Audit

Office 2007 Overview

SQL Server Reporting Services

Variable Data Printing in Fiery Controllers. Exercise 1: Fiery FreeForm 1

Excel Vba Manually Update Links On Open File Ignore

Table of Contents. LearnSmart

Date:.. /. / 20.. Remas Language Schools. Name :. Class : Second Term 5th Primary 1 Computer Department

Manual Vba Access 2010 Close Form Without Saving Record

Using Word 2011 at Kennesaw State University

Table of Contents. Word. Using the mouse wheel 39 Moving the insertion point using the keyboard 40 Resume reading 41

WinINSTALL 9.0 Master Document to be used as an internal resource only

Microsoft Office PowerPoint 2016: Part 1. Course Overview

Integrating Word, Excel, Access, and PowerPoint

Public Service Dossier PDF Development Tips

SmartArt Office 2007

As you can see, the basic job information is there the Job number, the Item, Quantity Released, etc.

Retrieve the shortcut properties from all the shortcuts in the Start Menu

Microsoft Certified Application Specialist Exam Objectives Map

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University : Advanced Applications of MS-Office

Delivering Information to the People Who Need to Know Carol Rigsbee, SAS Institute Chris Hemedinger, SAS Institute

BASIC EXCEL SYLLABUS Section 1: Getting Started Section 2: Working with Worksheet Section 3: Administration Section 4: Data Handling & Manipulation

Delivering Information to the People Who Need to Know Carol Rigsbee, SAS Institute Chris Hemedinger, SAS Institute

MS Word 2010 An Introduction

3. Centralize your title. To do this, click the Center button on the tab s paragraph group.

EVALUATION ONLY. Table of Contents. iv Labyrinth Learning

Getting Started with JMP at ISU

1. What s New Backstage New Save As Export Ribbon Using Templates Notes...

How to Create Custom Name Badge Inserts with a Mail Merge in Microsoft Word 2007

AVANTUS TRAINING PTE LTD

Slides & Presentations

EXCEL 2007 GETTING STARTED

Manually Create A Csv File From Excel 2010 Vba

Excel 2010 Level 1: The Excel Environment

Highline College Busn 216: Computer Applications for Business (Fun and Power with Computers) Office 2016 Video #12: PowerPoint

Learning Word Programming: Creating Word Macros And Beyond By PhD Steven Roman READ ONLINE

Microsoft Excel 2007 Macros and VBA

DOWNLOAD PDF VBA MACRO TO PRINT MULTIPLE EXCEL SHEETS TO ONE

How to make a power point presentation. Dr. Mohamed F. Foda

Contents SECTION-I : LINUX

BIM II IC3 & MOS Certification Pacing Guide

DOWNLOAD PDF EXCEL MACRO TO PRINT WORKSHEET TO

Microsoft Visual Basic Code Execution Has Been Interrupted Error

B.E. Publishing Correlations to The Office Specialist.com, 2E to Microsoft Office Specialist Word 2016 Core (77-725)

Computer Business Office Technology SLO to PLO Alignment(No Results)_February 2017

Excel 2013 Essentials Syllabus

Accessing Password Protected Microsoft Excel Files in A SAS Grid Environment

Dragon Printer ver. 1.0

JMP to LSAF Add-in. User Guide v1.1

Script.byu.edu SharePoint Instructions

Oracle Hyperion Essbase ASO common Questions and Answers

Microsoft Office Word 2010

Appendix A Microsoft Office Specialist exam objectives

1. AUTO CORRECT. To auto correct a text in MS Word the text manipulation includes following step.

Microsoft PowerPoint Tutorial

COMPUTERIZED OFFICE SUPPORT PROGRAM

Google Drive and Skydrive can be downloaded and synced to a computer just like Dropbox.

Ms Excel Vba Continue Loop Through Range Of

Make Your Word Documents Accessible

PAGES, NUMBERS, AND KEYNOTE BASICS

Transcription:

Using VBScript For Perfecting Statistical Report Ekaterina Torchinskaya, Data MATRIX Ltd., St. Petersburg, Russia Andrey Myslivets, Data MATRIX Ltd., St. Petersburg, Russia PhUSE 2017, CT11

Outline How we have come to VBScript Examples of using VBScript for.rtf documents How to write and launch VBScripts in SAS Other cases when VBS&SAS work How to get Visual Basic functions and procedures, if you are new to VBS (SPOILER: it s not ) 2

Motivation SAS Programmer`s responsibility is generating SARs Automation of the report development process Call of external programs Our choice for.rtf documents is 3

Let s look at VBS It s a variant of MS Visual Basic language VBS is recognizable for MS Office applications VBS code can be obtained from MS Word VBS can perform commands in MS Office that can t be executed in SAS 4

Let the replacement begin! I am ^m - page break I am was ^b - section break 5

It s time to start scripting The external script file is created in the specified directory: data _null_; file "C:\VBS_SAS\replace.vbs"; put " "; run; and has.vbs extension 6

Filling the script Use put operator to write VBS commands: Word.Applica9on object is created put "Dim wrdapp: Set wrdapp = WScript.CreateObject(""Word.Application"")"; The document to be transformed is opened put "Dim wrddoc"; put "Set wrddoc = wrdapp.documents.open(""&pth\&filename..&format"")"; 7

The power of special symbols Find all section break occurrences and replace them with page breaks put "wdreplaceall = 2"; put "wrddoc.select"; put "With wrdapp.selection.find"; put ".ClearFormatting"; put ".Replacement.ClearFormatting"; put ".Text = ""^b"""; put ".Replacement.Text = ""^m"""; put ".Forward = True"; put ".Wrap = wdfindcontinue"; put ".Format = False"; put ".MatchCase = False"; put ".MatchWholeWord = False"; put ".Execute,,,,,,,,,, wdreplaceall"; put "End With";.Text = ""^b"".replacement.text = ""^m"" 8

Other replacements put ".Text = ""^b"""; put ".Replacement.Text = "" """; ^b section break blank line 9

Save and close word document and script Save the document - wrddoc.saveas Close the document - wrddoc.close Close the application - wrdapp.quit put "wrddoc.saveas (""&infile."")"; put "wrddoc.close SaveChanges=True"; put "wrdapp.quit"; put "Set wrdapp = Nothing"; put "Set wrddoc = Nothing"; Quit the App 10

How the result looks like 11

Who runs the script? SAS! There are several ways to run the script from SAS: Manually from folder: "C:\VBS_SAS\replace.vbs" data _null_; call system("&path\&scriptname.vbs"); run; X "&path\&scriptname.vbs"; 12

Other tasks within the VBScript capabilities Merging many.rtf files into one Const wdpagebreak = 7 Obvious VBS/ If Then SAS Set objword = CreateObject("Word.Application") objword.visible = TRUE Set objdoc = objword.documents.add Set objselection = objword.selection objdoc.bookmarks("\endofdoc").range.insertfile "C:\VBS_SAS\TFLs\table01.rtf" objdoc.characters.last.select objselection.insertbreak(wdpagebreak) objdoc.bookmarks("\endofdoc").range.insertfile "C:\VBS_SAS\TFLs\table02.rtf" objdoc.characters.last.select objselection.insertbreak(wdpagebreak) objdoc.bookmarks("\endofdoc").range.insertfile "C:\VBS_SAS\TFLs\table03.rtf... Obvious SAS/ If Then VBS Const wrdpagebreak = 7 On Error Resume Next Set fso = CreateObject("Scripting.FileSystemObject") Set folder = fso.getfolder("c:\vbs_sas\tfls\") Set Files = folder.files Set objword = CreateObject("Word.Application") objword.visible = true Set objdoc = objword.documents.add Set objselection = objword.selection For Each fil In Files If (Right(LCase(fil), 4) = ".rtf" And InStr(fil, "~$") = 0) then objdoc.bookmarks("\endofdoc").range.insertfile fil.path objdoc.characters.last.select objselection.insertbreak(wdpagebreak) End If Next 13

Other tasks within the VBScript capabilities Automate SAS tasks, traverse the file system, send emails programmatically, manipulate Microsoft Excel, PowerPoint and other files, get web data. Develop SAS macros for PDF-manipulation, control and automation Perform automated and controlled analysis using JMP on the Windows platform and more 14

An easy way to start writing a simple VBScripts Using the developer tab MS Word customize ribbon options MS Word Record macro button Inserting the picture into the document Recorded macro in the MS Visual Basic for application 15

Conclusion VBS helps to automate the process of creating statistical reports Deals with MS Office documents Can be written and launched within SAS Allows to perform commands in MS Office that cannot be directly executed in SAS Necessary code can be obtained directly from Word 16

Thank you for your attention! Ekaterina Torchinskaya, ktorchynska@dm-matrix.com Andrey Myslivets, amyslivets@dm-matrix.com info@dm-matrix.com 17