Macro Examples for use with OMNIC Software
Issue
Here can be found a number of example macros that can be used with OMNIC software to perform various tasks.
Environment
OMNIC
Macros Basic
Example Macros
Macro File | Description | Special Instructions / Tips for Use |
---|---|---|
File Conversion Macros | ||
Used to convert a moderate number of spectral files to comma separated text file (.csv), GRAMS format (.spc), or to OMNIC format (.spa). | Can convert up to 100 files at a time. | |
Save to CSV from SPG.mac | Splits an OMNIC group spectral file (.spg) and resaves each spectrum to comma separted text file (.csv) | |
Save as CSV - Automatic Batch.mac | Used to convert a large number of .spa files to comma separated text files (.csv) |
Can convert up to 1000 files at a time. Reads file names to convert from a text file that is created from a batch file. Requires the macro "Create Batch file for Directory Listing.mac" be present in the C:\my documents\omnic\macros\ folder. |
Open Series Split Files and Save As CSV.mac | Converts .spa files that have been split from a Series (.srs) file to .csv files. | The Open task in the macro might need to be modified to specify the directory where the .spa files are located if different from C:\my documents\omnic\spectra\ |
Create Batch file For Directory Listing.mac | Function that can be called from within another macro. Creates a .bat file to create a text file that contains a directory listing of .spa files in a directory. |
Used with macro "Save as CSV - Automatic Batch.mac". Can be used to create listing of other types of files. Edit the "Math" task in the function to change the file extension from .spa to desired file extension. |
Save CSV files to worksheet horizontally - One X Axis Column.xlsm | Excel spreadsheet that contains a macro that will import the data from all .csv files in a directory. |
Run the excel macro "ImportCSVsWithReference" to import csv files. Puts X values in first column and Y values from all files in subsequent columns. Hint: All CSV files should have the same nubmer of data points and data spacing. Useful for importing data from a Split Series or Split Map command in OMNIC. |
Looping Data Collection | ||
collect sample - Looping with delay.mac | Simple looping data collection with saving of each spectra and a delay between collections | Prompts user at start for number of samples, delay time, and file base name. |
Looping Map Collection.mac |
A looping macro for collection of maps. Note: Map must be setup in Atlus window or Picta before starting the macro. |
General format of CollectMap command: CollectMap <map file name with path> <map title> ExecuteOMNIC “CollectMap C:\MyData\MyMap.map MyMap” Command with Index and spaces in path or filename: ExecuteOMNIC "CollectMap ""C:\my documents\omnic\Spectra\Map""#Index#"".map"" MyMap#Index#" Command with Index and no spaces: ExecuteOMNIC "CollectMap C:\Data\Map#Index#.map MyMap#Index#" |
Functions (can be called from withing another macro) | ||
Function - Replace Character in String.mac | Replaces all occurrences of one character in a string with a different character. |
Accepts 3 inputs: String, character to be replaced, and character to be used for replacement. Returns string with replaced characters. |
Remove Path from Filename.mac | Removes the path text from a string of the spectrum filename |
Accepts: String of filename Returns: String of filename without the path |
Exporting data to Text or Excel | ||
Spectrum Processing | ||
Library Automated Addition.mac | Automatically adds up to 100 spectra to a library. Will use spectrum title or filename for Compound Name. | Uses "Remove Path from Filename.mac" function to get filename when spectrum title is blank. |
Set title to filename.mac | Processes up to 100 spectra opened in the window and sets the spectrum title to the filename (without the file path). |