Quantcast
Channel: Indigo Rose Software Forums - Forums
Viewing all articles
Browse latest Browse all 2105

Print Excel Sheet / Don't Save from Luacom

$
0
0
Hi All,
Doing a Job for local Charity and have run into a Road Block
I'm trying to automate printing and not saving excel after exporting grid to excel via luacom plugin
I've searched my old archives , the forum and Google but cannot find any method

Click image for larger version

Name:	GMS.jpg
Views:	11
Size:	252.7 KB
ID:	310627

Code:
------------------------------[[ SCRIPT: Page: Menu, Object: Button6, Event: On Click Script ]]------------------------------
Application.Minimize();

local oExcel = luacom.CreateObject("Excel.Application");
if oExcel then
oExcel.Visible = 1;--Set to dispay or hide excel
--oExcel.WorkBooks:Add();
oExcel.Workbooks:Open(_SourceFolder.."\\Autoplay\\ Docs\\Monthly Statement.xlsx")
oExcel.ActiveWorkbook.Sheets(1):Select();
oExcel.ActiveSheet.Cells(7,4).FormulaR1C1 = Input.GetText("LongDInput");
oExcel.ActiveSheet.Cells(9,3).FormulaR1C1 = Input.GetText("OpenBalInput");
oExcel.ActiveSheet.Cells(47,3).FormulaR1C1 = Input.GetText("CloseBalInput");
ITotal = 0
ETotal = 0
R=11
X=27
--Income
for row in db:nrows("SELECT * FROM Cashbook WHERE Income > 0 and Strftime(\"%m\", Date)= '"..Curr_Mth.."'") do
R=R+1

yr = String.Left(row.Date, 4);
month = String.Mid(row.Date, 6, 2);
day = String.Right(row.Date, 2);
iDate = day.."-"..month.."-"..yr

sSpent = Currency.Format(row.Income, LOCALE_USER_DEFAULT)

sCat = row.Category

sType = row.Type
ITotal = ITotal + row.Income
sTotal = Currency.Format(ITotal, LOCALE_USER_DEFAULT)
oExcel.ActiveSheet.Cells(R, 2).FormulaR1C1 = sCat;
oExcel.ActiveSheet.Cells(R, 3).FormulaR1C1 = sSpent;
oExcel.ActiveSheet.Cells(R, 4).FormulaR1C1 = sType;
oExcel.ActiveSheet.Cells(R, 5).FormulaR1C1 = iDate;
--Dialog.Message("Info", sTotal, MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
oExcel.ActiveSheet.Cells(25, 3).FormulaR1C1 = sTotal;
end
for row in db:nrows("SELECT * FROM Cashbook WHERE Expense > 0 and Strftime(\"%m\", Date)= '"..Curr_Mth.."'") do
X=X+1

yr = String.Left(row.Date, 4);
month = String.Mid(row.Date, 6, 2);
day = String.Right(row.Date, 2);
iDate = day.."-"..month.."-"..yr

sSpent = Currency.Format(row.Expense, LOCALE_USER_DEFAULT)

sCat = row.Category

sType = row.Type
ETotal = ETotal + row.Expense
sTotal = Currency.Format(ETotal, LOCALE_USER_DEFAULT)
oExcel.ActiveSheet.Cells(X, 2).FormulaR1C1 = sCat;
oExcel.ActiveSheet.Cells(X, 3).FormulaR1C1 = sSpent;
oExcel.ActiveSheet.Cells(X, 4).FormulaR1C1 = sType;
oExcel.ActiveSheet.Cells(X, 5).FormulaR1C1 = iDate;
--Dialog.Message("Info", sTotal, MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
oExcel.ActiveSheet.Cells(46, 3).FormulaR1C1 = sTotal;

end

-- tried vbs here
end
--oExcel:Quit()​
I have tried running various VBS codes but to NO avail , the only Luacom code found was print(oExcel.ActiveSheet)
but that did not work

At the moment the prog minimizes , opens Excel from where yuo can print the Shheet , then either Save / Do Not Save when closing Excel

I am trying to get this done Automatically with no user intervention

Any Help will be appreciated

Viewing all articles
Browse latest Browse all 2105

Trending Articles