December 7, 2009

MacroScript SDK – Run Macro Code Within Your Apps

Filed under: Announcements — Marcus Tettmar @ 9:55 pm

I’ve often been asked by other application developers if there is a way they can run Macro Scheduler code from within their applications. They may need their software to automate some other application, or they may want to give their users the ability to write macros within their program. Sometimes developers just want to make use of some of the unique features available in Macro Scheduler from within their own applications.

Until now the only way another application could run a Macro Scheduler macro would be for it to shell a .scp or compiled .exe via the command line. But this has its limitations and licensing implications.

Today I can announce the availability of the MacroScript Software Development Kit. The MacroScript SDK allows application developers to integrate the Macro Scheduler language right into their software so that Macro Scheduler code can be executed directly and seamlessly. Code can be executed transparently, and the result of macros and variables retrieved.

The SDK provides two interface methods: a DLL and an ActiveX component. This means it is compatible with pretty much any development language/IDE, including Visual Studio (VB, C#, C++) and Borland IDEs (Delphi, C++). Anything that can use a DLL or an ActiveX component can use the SDK and execute Macro Scheduler code. That includes Microsoft Office VBA, and even plain old VBScript and web pages.

Naturally we need to be careful who gets hold of this. For obvious reasons we wouldn’t want someone using our SDK to create a product that competes with Macro Scheduler. For that reason we’re asking for people to contact us with their requirements if they are interested in giving it a go.

So for more info please go here.

If you know of a product that would benefit from having MacroScript built in why not send the developers a link to this blog.

December 2, 2009

Tis the Season to .. Automate

Filed under: Automation, General — Marcus Tettmar @ 11:45 am

Crumbs, is it really already December? Christmas always seems to creep up on me unprepared. Always so much to do and organise. Most people will be winding down and spending time with friends and family. But in our modern 24×7 culture many businesses still keep running. Web sites and servers still need monitoring, reports generating, data transferring, networks maintained, users, customers and holiday shoppers supported.

How many of us end up “on call” or remoting into the office network to check things over and ensure those pesky systems keep working and processes keep ticking over without causing us more work when we get back in the New Year?

A lot of these things can be automated. Macro Scheduler could be helping you relax this Christmas. It’s a good time to look at your processes and see what could be streamlined. What can be automated to prevent key staff having to log in from home, or made easier for skeleton staff to operate?

In the UK we have new VAT rules coming into effect on 1st January. I wonder how many people will be logging in on New Year’s Day to update their tax codes. We’ve already got a macro set up to do just that, scheduled for 1 minute past midnight.

What will you be automating this Christmas?

November 30, 2009

November 25, 2009

T-Shirt Design Contest – Win a Kindle!

Filed under: Announcements, General — Marcus Tettmar @ 10:14 am

Win an Amazon Kindle! Over at Zazzle you can find a range of T-shirts and merchandise sporting the MJT Net Gearhead logo. The really cool thing about Zazzle is that you can customize the products and come up with your own creations. You can add text and even other images.

So we thought it would be fun to get the creative juices flowing. Can you come up with a humorous, punchy slogan for this T-shirt?

You can customize the T-shirt as much as you like as long as the logo and URL are shown prominently. Perhaps you can find something witty to say about Macro Scheduler and why it helps you. Oh and keep it clean.

Click on the image to view the T-shirt and start customizing. Post links to your designs in the comments below. In February we’ll choose our favourite design and send the winner the final product and a free Amazon Kindle (Global Wireless) worth $259!

Update: Last date for entries is 31st January 2010.

Update: Some people have had trouble trying to publish a link to their T-shirt designs and we’ve been unable to view them. We’ve found the quickest way, which avoids creating a store, is to do this: Customize the T-Shirt. When you’re done click on “Email” right underneath the “Add to Cart” section. If you don’t already have an account you’ll be asked to create one and then you’ll get a box to enter an email address. Enter your own email address to email the design to yourself. If you like enter [email protected] as well so that we also get a copy. Check your email to find the link and then paste it into a comment here.

If you need to get back to your design, log in and click on “My Account” at top right and then “In Progress Designs”. If it’s not there it may be in “Private” or “Public” under “My Products”.

November 11, 2009

Macro Scheduler 11.1.17 Update

Filed under: Announcements — Marcus Tettmar @ 11:11 am

Macro Scheduler 11.1.17 is now available with the following changes:

  • Fixed: GetWindowProcess unable to get filename on Vista/Win7 x64
  • Fixed: When run in Editor macros called by Macro command will animate icon and leave animated on completion
  • Fixed: Window commands – if wildcard not specified child/MDI windows would not be found

Registered Downloads/Upgrades | Evaluation Downloads | New License Sales

November 10, 2009

eDocfile: Automated Optical Technology Supports World’s Second-Largest Medical Vaccine Trial

Filed under: Success Stories — Marcus Tettmar @ 3:52 pm

By Keith Passaur, president and owner, eDocfile, Inc., Valrico, Florida

eDocfile is a consulting firm that specializes in creating image-capture programs to increase our clients’ productivity. Over the past seven years, we’ve used Macro Scheduler in virtually every project we take on, so we don’t have to “recreate the wheel” each time we need to provide the same automation steps.

In early 2009, we were contracted by a consulting firm in The Netherlands for a small programming project. A few weeks later, they contacted us again—this time with something much larger and much more challenging in mind. Their client, a Dutch hospital, needed automation assistance to support a very large, multi-site medical vaccine trial—it would, in fact, be the second-largest project of its kind ever, involving 85,000 patients. In all, 340,000 documents—or 4,000 documents each day—would have to be scanned with Optical Character Recognition (OCR) technology for automated filing. File by OCR, one of the products we offer, had already been purchased. File by OCR works with searchable pdf or tiff files to automatically perform OCR and extract text. The extracted text is parsed and used to rename and relocate the file to build a file folder hierarchy.

The consultants asked us to modify File by OCR so the hospital’s vaccine-trial files could be named based on index information (patient number, center number, and document type).

Scanning Forms for Faxing, OCR Filing

To make sure the customized program would work as intended for the clinical staff, it was important that we completely understood how the data would be collected, transmitted, and entered into the program. Since OCR would read data from a pre-printed form that could not be altered (such as by adding a barcode), we requested original copies.

We received a six-page tri-fold form that each patient would complete. On the third page, a distinct vertical number, readable by OCR, contained the patient number and center number where the form was generated. We were told the completed forms would be scanned at each remote center in a duplex manner, creating a two-page tiff file for sending to the hospital. There, the scanned image would be separated into six individual pages and the vertical number extracted for filing. The file would then be re-assembled into a five-page pdf (page 6 of the form was blank) for automatic filing. All processing of documents would be done in a batch process after scanning, freeing the users to move on to other tasks while the OCR process was underway.

Seeing the forms and understanding the procedure, we were able to modify File by OCR so the incoming documents could be stored in a logical file folder hierarchy, separated by center. Because they would be kept in a completely non-proprietary format, the documents could be imported into any database and a hyperlink assigned for retrieval.

Macro Scheduler Speeds Filing, Data Verification

Because each document would be read with OCR and filed using the same steps, we used Macro Scheduler to automate initiating the file command lines. Macro Scheduler allows us to use regular expressions to parse text and automate the moving and renaming of files. Once the steps are put together in the script, they can easily be modified for use in other programs to automate similar actions.

Each center had been assigned a certain range of patient numbers, so to check for missing or misfiled documents we created a macro that compared the list of assigned numbers for that center to patient numbers to validate the OCR. Also, since all files must be accounted for, a macro was created to extract the patient number, center number, and the trial stage from an Excel spreadsheet for validation.

Catching OCR Errors

Because OCR is not 100% accurate, we wrote scripts that would test and retest the data captured for any errors. The net result is 1 error per 1,000 scanned images. Those with errors must be processed manually.

The Dutch consultants installed our Macro Scheduler-enhanced program in fall 2009, and the complete process was validated by an external auditing company.

The hospital is processing 1,300 documents and more than 2,600 faxes daily. Users manually process the three or four fails each day with the manual processing tools built into the software.

We think this is a great example of how Macro Scheduler can be used to automate several repetitive steps in an environment where everything must be executed flawlessly, with redundant cross-checking and seamless integration.

The Dutch consultants were pleased, and, in fact, they’ve said they’ll be calling us again very soon, perhaps with something even bigger in mind….

Keith Passaur can be reached at [email protected], 813-413-5599

November 5, 2009

How to Sort a CSV File

Filed under: Automation, Scripting — Marcus Tettmar @ 11:39 am

This morning, forum user hip asked how a script could sort a CSV file. Seems CSV files, sorting and Excel has become a bit of a hot topic here lately. Since Excel can read and save to CSV and also has a Sort function we might as well make use of it. Here’s a little VBScript function I put together which will sort a CSV file by a given column:

VBSTART
Sub SortCSVFile(file,sort_column)
  Set XLApp = CreateObject("Excel.Application")
  XLApp.Workbooks.Open(file)
  
  XLApp.ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear
  Set SortCol = XLApp.Range(sort_column)
  XLApp.ActiveWorkbook.ActiveSheet.Sort.SortFields.Add(SortCol)
  Set Cell = XLApp.ActiveWorkbook.ActiveSheet.Cells.Find("*", XLApp.ActiveWorkbook.ActiveSheet.Cells(1, 1),,,,2)
  Set mYRange = XLApp.Range("A1", XLApp.ActiveWorkBook.ActiveSheet.Cells(Cell.Row, Cell.Column))
    
  XLApp.ActiveWorkbook.ActiveSheet.Sort.SetRange(mYRange)
  XLApp.ActiveWorkbook.ActiveSheet.Sort.Apply
  
  XLApp.ActiveWorkBook.Save
  XLApp.ActiveWorkBook.Close false
  XLApp.quit
End Sub
VBEND

The function opens the CSV file in Excel – without making Excel visible – then performs the sort, saves the file and closes Excel. You won’t see Excel appear on the screen.

Here’s how to use it. If you want to sort your file on column B and don’t have a header row, use:

VBRun>SortCSVFile,C:\Documents\my.csv,B1

To sort on column A and you DO have a header row use:

VBRun>SortCSVFile,C:\Documents\my.csv,A2

UPDATE: Here’s a simplified version which should work in Excel XP/2003 and should be able to detect whether or not your data has a header row:

VBSTART
Sub SortCSVFile(file,sort_column)
  Set XLApp = CreateObject("Excel.Application")
  XLApp.Workbooks.Open(file) 
  XLApp.ActiveWorkbook.ActiveSheet.Range("A1").Sort XLApp.ActiveWorkbook.ActiveSheet.Range(sort_column),,,,,,,0  
  XLApp.ActiveWorkBook.Save
  XLApp.ActiveWorkBook.Close false
  XLApp.quit
End Sub
VBEND

What if you don’t have Microsoft Excel?

As mentioned in my reply on the forum another method you could use is to open the CSV file as a recordset using DBQuery and apply an “ORDER BY” clause to your SQL statement. That would sort it into memory. Then you would need to loop through the array and write the data back out to a CSV file using WriteLn.

Something like:

//new file to write to
Let>new_file=%SCRIPT_DIR%\example_sorted.csv
IfFileExists>new_file
  DeleteFile>new_file
Endif

//set WriteLn NOT to add line breaks (we'll add those ourselves)
Let>WLN_NOCRLF=1
//The CSV delimiter
Let>comma=,

//Connect to and query the CSV using ORDER BY PRICE to sort on Price column
Let>ConStr=Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%SCRIPT_DIR%;Extended Properties='text;HDR=YES;FMT=Delimited'
DBConnect>ConStr,dbH
DBQuery>dbH,select * from example.csv ORDER BY PRICE,fields,num_recs,num_fields

//If we have records, loop through records and fields, writing out to new file
If>num_recs>0
  //first need to copy the header record ...
  ReadLn>%SCRIPT_DIR%\example.csv,1,header_line
  WriteLn>new_file,wlnres,%header_line%%CRLF%

  //the loop
  Let>rec=0
  Repeat>rec
    Let>rec=rec+1
    Let>field=0
    Repeat>field
      Let>field=field+1
      Let>this_field=fields_%rec%_%field%
      //write the field out to the new file
      WriteLn>new_file,wlnres,this_field
      //add the comma delimiter if needed
      If>field<num_fields
        WriteLn>new_file,wlnres,comma
      Endif
    Until>field=num_fields
    //add CRLF at end of line
    WriteLn>new_file,wlnres,%CRLF%
  Until>rec=num_recs
Endif
DBClose>dbH

//if you want, delete the input file and replace with the new sorted one:
//DeleteFile>%SCRIPT_DIR%\example.csv
//RenameFile>%SCRIPT_DIR%\example_sorted.csv,%SCRIPT_DIR%\example.csv

November 2, 2009

October 30, 2009

Convert XML to CSV

Filed under: Automation, Scripting — Marcus Tettmar @ 12:27 pm

Earlier this month I wrote about how you can read and write data from/to CSV files as if they were database tables using DBQuery. Andrew asked if I knew of a way that XML files could be treated as database tables in the same way. I did find a couple of references to some ODBC drivers online but one was not yet available and the other was part of a larger commercial package so I was unable to try them.

Since then it has occurred to me that there is a way we can convert XML files to CSV (or XLS) files using Excel. Once the data is in CSV file format we can then retrieve it easily using DBQuery.

The more technically aware will probably ask why we can’t just use the MSXML.DomDocument object in VBScript to read in the XML and parse it. Well, while that is of course possible, many will find the ability to access the XML data in a tabular database-like format easier and more familiar.

So, without further ado, here’s my ConvertXMLtoCSV function:

VBSTART
Sub ConvertXMLtoCSV(xmlFile,csvFile)
    Set xlApp = CreateObject("Excel.Application")
    Set xlBook = xlApp.Workbooks.OpenXML(xmlFile,2)
    xlBook.SaveAs csvFile, 6
    xlBook.close false
    xlApp.quit
End Sub
VBEND

You will need Excel installed for this to work. Use the function like this:

VBRun>ConvertXMLtoCSV,c:\docs\my.xml,c:\docs\converted.csv

And now you can quickly read the data into an array using DBQuery.

The function works quietly in the background. You won’t see Excel open – just a short delay while the CSV file is created.

To convert to an Excel file rather than a CSV file change the code to:

VBSTART
Sub ConvertXMLtoXLS(xmlFile,xlsFile)
    Set xlApp = CreateObject("Excel.Application")
    Set xlBook = xlApp.Workbooks.OpenXML(xmlFile,2)
    xlBook.SaveAs xlsFile, 56
    xlBook.close false
    xlApp.quit
End Sub
VBEND

Please note I’m using Excel 2007 and haven’t tried this with earlier versions though I believe Excel 2003 can also read from XML files. Success may also depend on the format of your XML.

See:
Reading From CSV Files
More on Reading and Writing CSV Files
Retrieve Entire Excel Sheet Using DBQuery

October 29, 2009

Quick Sort Routine

Filed under: Uncategorized — Marcus Tettmar @ 8:00 am

Back in 2006 I posted an example of a Bubble Sort or Insert Sort algorithm. In this more recent forum post, azzkicker_9002 asks for help creating a Quicksort function which is faster for longer lists. So I took the example found here on the alogorithmist website and converted it to MacroScript. I tried to post the code here but it screwed up WordPress, so you’ll have to head on over to the forum to see it.