[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-glpk] printf to a file in the correct directory

From: joel mortyn
Subject: [Help-glpk] printf to a file in the correct directory
Date: Tue, 24 Feb 2015 06:24:05 +1100

Hi all,

I have developed an LP with the user interface in MS Excel. I am using the printf command to print selected results to a text file as follows:
printf{s in Sorts} %d\n", SortQc[s] >> "result.txt";

The result.txt file is located in the same directory as the model and data files. When I run the program using the Gusek GUI, all works fine and the result.txt file writes to the correct directory. 

The problem is, that when I run the program from Excel (using the command line executable cmd.exe), it saves the result.txt file to C:\Users\me\Documents rather than the same directory as the model and data files. I have used the same code many times previously in MS Access with no issue but this is the first time I've tried it in Excel. I've compared the code from Access and Excel and can't find any differences so I'm stumped as to what might be the problem. 

Has anyone else experienced issues like this before?
Below is some of the VBA code that I am using to run the model from Excel:

strArgument = strPathName & "glpsol.exe --model " & strModelName & " --data " & strFileName
BatchName = strPathName & "tempfile.bat"
intEmpFileNbr = FreeFile
Open BatchName For Output As #intEmpFileNbr
        Print #intEmpFileNbr, strArgument
Close #intEmpFileNbr
Call ShellandWait("cmd.exe /c " & BatchName)

Thanks for any assistance that you might be able to provide.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]