oh boy, this is taking me a long time to solve but i have learned alot in the process... i have a problem here, i want to put my lblFishvalue.caption into the end of file on the column "E" my problem is i dont know what function or object should i use, i have been reading those objects for more than an hour now, with no success... did i miss something out? tnx in advance....![]()
my problem is here in this set of codes:Code:Private Sub CmdPrint_Click() Dim iRow As Long Dim iCol As Long Dim newcell As String Dim lastcol As Range Dim currentcell As Range Dim xls As excel.Application Dim XLSbook As excel.Workbook Dim xlssheet As excel.Worksheet Set xls = New excel.Application Set XLSbook = xls.Workbooks.Open(App.Path & "\book1.xls") DoEvents xls.Visible = True For iRow = 0 To MSFlexGrid1.Rows - 1 For iCol = 0 To MSFlexGrid1.Cols - 1 MSFlexGrid1.Col = iCol MSFlexGrid1.Row = iRow newcell = Chr(iCol + 65) & iRow + 1 xls.Worksheets("sheet1").Range(newcell).Value = MSFlexGrid1.Text Next Next 'AutoFormat xls.Selection.AutoFormat Format:=xlRangeAutoFormatList1 'Center all in A With xls .Columns("A:A").Select Selection.HorizontalAlignment = xlCenter End With 'center all in B With xls .Columns("B:B").Select .Selection.HorizontalAlignment = xlCenter End With 'Center all in E xls.Columns("E:E").Select With xls.Selection .HorizontalAlignment = xlCenter .Selection.Style = "currency" 'Set the currency End With 'last column of E put the lblfishvalue Set currentcell = xls.Column("e2").Select lastcol = xlssheet.Range("E2").End(xlDown).Column xls.ActiveCell.Value = lblFishValue.Caption 'Save workBook as ReadOnly File with password XLSbook.SaveAs ("C:\Documents and Settings\coa\My File.xls"), , , ("123"), (True), , xlShared, (xlUserResolution) 'close Set XLSbook = Nothing Set xls = Nothing End Sub
Code:'last column of E put the lblfishvalue Set currentcell = xls.Column("e2").Select lastcol = xlssheet.Range("E2").End(xlDown).Column xls.ActiveCell.Value = lblFishValue.Caption




Reply With Quote