Using Windows 10, Octave 4.4.1, and Excel 2016, I have an Octave script (call it "MyOctaveProgram.m") that takes data from a text file ("MyTextFile.txt"), which can be loaded with the uigetfile function, but for quicker access, I've created a batch file:
@echo off
C:\Octave\Octave-4.4.1\octave.vbs --force-gui --eval MyOctaveProgram("'%~d0%~p0'","'%~n0'")
cmd /c
The .bat file has the same name as the .txt file, other than the extension.
So far, this all works fine, and I can execute part of MyOctaveProgram.m via the GUI command line, or through the batch file. The difference comes in when I try to use a part of my code that creates a data table in Excel (with the COM interface), using
xls=xlsopen(ExcelFile)
xls=oct2xls(data...)
xls=oct2xls(more data...)
xls=oct2xls(etc...)
xlsclose(xls)
This works fine when I run MyOctaveProgram.m from the GUI command line (choosing MyTextFile.txt with the uigetfile function), but when I try to create the Excel file when running Octave through the batch script above, I get the following message:
(File pointer preserved. Try saving again later...)
This seems to produce no errors, and the session stays open (unlike the GUI, the batch-initiated Octave session will terminate if there's an error), but the Excel file is not created. There are no other Excel windows or tasks open, and I'm not trying to overwrite an existing file. Any advice would be appreciated!
@%SystemRoot%\System32\cscript.exe //NoLogo "C:\Octave\Octave-4.4.1\octave.vbs" --force-gui --eval MyOctaveProgram("'%~dp0'"^,"'%~n0'")and nothing else and run this batch file from within a command prompt window by typing its full qualified file name (drive + path + name + extension) enclosed in"and pressing ENTER or RETURN instead of double clicking on this batch file?xlsopen(filename,1), I'm using the input function, i.e.description = input('Input file description: ',"s"); filename = ["Output-" description ".xlsx"]; xls = xlsopen(filename,1);This doesn't work (same as original problem), butfilename="Output.xlsx";works. This isn't a permanent solution; I need multiple files, but getting there!