<< Click to Display Table of Contents >> Navigation: 3. Script Language > Browser and Office (Acc.-Engine) > OFC. - Office-Commands > MS-Excel Scripting > OFC. - Office-Commands |
MiniRobotLanguage (MRL)
OFC.Excel|SAVEAS
SAVE MS-Excel worksheet via the SPR using a Filename
Intention
Generally you will need to OPEN a Excel-Instance first, this is done using the "OPEN" Subcommand.
To SAVE your Excel-Worksheet, use the SAVEAS Subcommand.
There is one Parameter, that will force Excel to suppress any Error-Messages like "File exists" etc.
Set the Force Flag to "1" if you want Excel to Save your Files anyway (if possible with the given name and path).
You can use the "SET" Commands to save with a Password and for other Options.
The Command will drop an "1" on the TOS if it was successful, otherwise a "0".
Syntax:
OFC.Excel|SAVEAS[|P1][|P2][|P3][|P4]
Parameter Explanation:
Filename$, Filetype&,Quite& (1-keine Alerts/0-Alerts),Create_Backup& (1/0)
P1 - (Text) Filenpath&Filename
P2 - (opt,numeric) - Fileformat - leave zero to use Standard "xlTextWindows" alternative numbers see below in "Remarks" Section. (default 0)
P3 - (opt,0/1) - FORCE Flag suppress Error-Messages and force Excel to SAVEAS even if the file already exists
P4 - (opt,0/1) - Generate Backup on Save (default 0)
Example:
' Excel SAVEAS Example
VAR.$$PFA=?path\Test5.xls
' Open New empty Sheet
OFC.excel|OPEN||0|1
' Activate by name
OFC.excel|SHEET_Activate|2
' Save as Filename
OFC.excel|SAVEAS|$$PFA
MBX.!
' Write some numbers into Sheet
OFC.excel|FORMULA|A1:B10|2
' SAVE
OFC.excel|SAVE
' Show Stack
DMP.6
MBX.Click to Close
OFC.excel|CLOSE|1
END.
Remarks:
You can use the "SET" Commands to save with a Password and for other Options.
XlFileFormat - please use the numbers on the right side:
xlAddIn = 18 ' &H00000012
xlCSV = 6 ' &H00000006
xlCSVMac = 22 ' &H00000016
xlCSVMSDOS = 24 ' &H00000018
xlCSVWindows = 23 ' &H00000017
xlDBF2 = 7 ' &H00000007
xlDBF3 = 8 ' &H00000008
xlDBF4 = 11 ' &H0000000B
xlDIF = 9 ' &H00000009
xlExcel2 = 16 ' &H00000010
xlExcel2FarEast = 27 ' &H0000001B
xlExcel3 = 29 ' &H0000001D
xlExcel4 = 33 ' &H00000021
xlExcel5 = 39 ' &H00000027
xlExcel7 = 39 ' &H00000027
xlExcel9795 = 43 ' &H0000002B
xlExcel4Workbook = 35 ' &H00000023
xlIntlAddIn = 26 ' &H0000001A
xlIntlMacro = 25 ' &H00000019
xlWorkbookNormal = -4143 ' &HFFFFEFD1
xlSYLK = 2 ' &H00000002
xlTemplate = 17 ' &H00000011
xlCurrentPlatformText = -4158 ' &HFFFFEFC2
xlTextMac = 19 ' &H00000013
xlTextMSDOS = 21 ' &H00000015
xlTextPrinter = 36 ' &H00000024
xlTextWindows = 20 ' &H00000014
xlWJ2WD1 = 14 ' &H0000000E
xlWK1 = 5 ' &H00000005
xlWK1ALL = 31 ' &H0000001F
xlWK1FMT = 30 ' &H0000001E
xlWK3 = 15 ' &H0000000F
xlWK4 = 38 ' &H00000026
xlWK3FM3 = 32 ' &H00000020
xlWKS = 4 ' &H00000004
xlWorks2FarEast = 28 ' &H0000001C
xlWQ1 = 34 ' &H00000022
xlWJ3 = 40 ' &H00000028
xlWJ3FJ3 = 41 ' &H00000029
xlUnicodeText = 42 ' &H0000002A
xlHtml = 44 ' &H0000002C
xlWebArchive = 45 ' &H0000002D
xlXMLSpreadsheet = 46 ' &H0000002E
xlExcel12 = 50 ' &H00000032
xlOpenXMLWorkbook = 51 ' &H00000033
xlOpenXMLWorkbookMacroEnabled = 52 ' &H00000034
xlOpenXMLTemplateMacroEnabled = 53 ' &H00000035
xlTemplate8 = 17 ' &H00000011
xlOpenXMLTemplate = 54 ' &H00000036
xlAddIn8 = 18 ' &H00000012
xlOpenXMLAddIn = 55 ' &H00000037
xlExcel8 = 56 ' &H00000038
xlOpenDocumentSpreadsheet = 60 ' &H0000003C
xlOpenXMLStrictWorkbook = 61 ' &H0000003D
xlCSVUTF8 = 62 ' &H0000003E
xlWorkbookDefault = 51 ' &H00000033
For technical details see:
https://msdn.microsoft.com/de-de/library/microsoft.office.interop.excel.xlfileformat.aspx
Limitations:
These commands need an valid Installation of MS-Office Excel. It will check if MS Excel is properly installed, and if not just do nothing.
The SAVE Subcommand will only work with Excel-Instances that have previously been opened with the OPEN Subcommand of the same Robot-Instance.
If the command succeeds, it will drop an "1" on the TOS.
See also: