Вы находитесь на странице: 1из 1

Dim xls As New Excel.

Application
Dim strSQL As String
strSQL = "select * from stock order by nama_barang"
datStock.RecordSource = strSQL
datStock.Refresh
datStock.Recordset.MoveFirst
With xls
.Workbooks.Open App.Path & "\stock_temp.xls", , True
.Sheets("saldo_stock").Select
posx = 4
datStock.Recordset.MoveFirst
Do While datStock.Recordset.EOF = False
.Cells(posx, 1) = datStock.Recordset!nama_barang
.Cells(posx, 2) = Int(datStock.Recordset!saldo_Display)
.Cells(posx, 3) = Int(datStock.Recordset!saldo_53A)
.Cells(posx, 4) = Int(datStock.Recordset!saldo_53B)
.Cells(posx, 5) = Int(datStock.Recordset!saldo_43)
.Cells(posx, 6) = Int(datStock.Recordset!saldo_Royal)
posx = posx + 1
datStock.Recordset.MoveNext
Loop
ChDir App.Path & "\Report"
.ActiveWorkbook.SaveAs FileName:=App.Path & "\Report\Stock - " & Text1.T
ext & " - " & Format(Date, "yyyymmdd") & ".xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=F
alse _
, CreateBackup:=False
.Visible = True
.ActiveWindow.SelectedSheets.PrintPreview
.Application.DisplayAlerts = False
'.Quit
End With