Hi all,
I am creating a database using vb6 and excel
I coded in the way to accept data from the user and made it to pass the values to an excel sheet
I manually created an excel file in my computer's D: drive and named it as "Database"
And I coded in a module named "Appending" to open the excel file to save the data which i am passing through code
If I am running the application it asks for the data from the user..when i enter all the data and saving it ya it is successfull and the data get saved in the excel file
i stopped running the application and closed all the user interaction windows. ya i am successfull again
But when i stopped running the application but without closing other user interaction form , i enetered new set of data and tried to save it
It is promptimg me to save the changes as usual
If i gave yes "Save As" dialog box gets opened asking me to save the file as (copy of "filename")
I am not sure where i am going wrong
Following is my code
************************************************** **
Sub Appending(TBooksNames As String, BooksNames As Variant, TNoOfBooks As String, NoOfBooks As Integer, TSenderName As String, SenderName As Variant, TRecipientName As String, RecipientName As Variant, TGender As String, Gender As String, TStreetNo As String, StreetNo As Variant, TCity As String, City As String, TState As String, State As String, TPostCode As String, PostCode As Long, TDateAndTime As String, DateAndTime As Variant)
Dim oXLApp As Excel.Application
Dim oXLBook As Excel.Workbook
Dim oXLSheet As Excel.Worksheet
Dim oXLRange As Excel.Range
Dim newFstRow As Integer
Dim newFstCell As Variant
Dim newScndCell As Variant
Dim BlankRow As Integer
Dim BlankRowNum As Integer
Dim BlankRowCell As Variant
Dim NextToBlankRow As Integer
Dim TitleRowCell As Variant
TBksNames = TBooksNames
BksNames = BooksNames
TNoOfBks = TNoOfBooks
NoOfBks = NoOfBooks
TSenName = TSenderName
SenName = SenderName
TRecName = TRecipientName
RecName = RecipientName
TGen = TGender
Gen = Gender
TStrNo = TStreetNo
StrNo = StreetNo
TCit = TCity
Cit = City
TSta = TState
Sta = State
TPstCd = TPostCode
PstCd = PostCode
TDtAndTime = TDateAndTime
DtAndTime = DateAndTime
Set oXLApp = New Excel.Application
Set oXLBook = oXLApp.Workbooks.Open("D:\Hema\Database.xls")
Set oXLSheet = oXLBook.Worksheets(1)
Set oXLRange = oXLSheet.UsedRange
'oXLRange.SpecialCells(xlCellTypeLastCell).Activat e
BlankRow = ActiveSheet.Range("a65536").End(xlUp).Offset(1, 0).Row
'BlankRowNum = oXLApp.ActiveCell.Row + 1
BlankRowCell = "A" & BlankRowNum
NextToBlankRow = ActiveSheet.Range(BlankRowCell).End(xlDown).Offset (1, 0).Row
TitleRowCell = "A" & NextToBlankRow
ActiveSheet.Range(TitleRowCell) = "BOOKS RECORD"
oXLRange.SpecialCells(xlCellTypeLastCell).Activate
newFstRow = oXLApp.ActiveCell.Row + 1
newFstCell = "A" & newFstRow
ActiveSheet.Range(newFstCell) = TBksNames
newScndCell = "B" & newFstRow
ActiveSheet.Range(newScndCell) = BksNames
oXLRange.SpecialCells(xlCellTypeLastCell).Activate
newFstRow = oXLApp.ActiveCell.Row + 1
newFstCell = "A" & newFstRow
ActiveSheet.Range(newFstCell) = TNoOfBks
newScndCell = "B" & newFstRow
ActiveSheet.Range(newScndCell) = NoOfBks
oXLRange.SpecialCells(xlCellTypeLastCell).Activate
newFstRow = oXLApp.ActiveCell.Row + 1
newFstCell = "A" & newFstRow
ActiveSheet.Range(newFstCell) = TSenName
newScndCell = "B" & newFstRow
ActiveSheet.Range(newScndCell) = SenName
oXLRange.SpecialCells(xlCellTypeLastCell).Activate
newFstRow = oXLApp.ActiveCell.Row + 1
newFstCell = "A" & newFstRow
ActiveSheet.Range(newFstCell) = TRecName
newScndCell = "B" & newFstRow
ActiveSheet.Range(newScndCell) = RecName
oXLRange.SpecialCells(xlCellTypeLastCell).Activate
newFstRow = oXLApp.ActiveCell.Row + 1
newFstCell = "A" & newFstRow
ActiveSheet.Range(newFstCell) = TGen
newScndCell = "B" & newFstRow
ActiveSheet.Range(newScndCell) = Gen
oXLRange.SpecialCells(xlCellTypeLastCell).Activate
newFstRow = oXLApp.ActiveCell.Row + 1
newFstCell = "A" & newFstRow
ActiveSheet.Range(newFstCell) = TStrNo
newScndCell = "B" & newFstRow
ActiveSheet.Range(newScndCell) = StrNo
oXLRange.SpecialCells(xlCellTypeLastCell).Activate
newFstRow = oXLApp.ActiveCell.Row + 1
newFstCell = "A" & newFstRow
ActiveSheet.Range(newFstCell) = TCit
newScndCell = "B" & newFstRow
ActiveSheet.Range(newScndCell) = Cit
oXLRange.SpecialCells(xlCellTypeLastCell).Activate
newFstRow = oXLApp.ActiveCell.Row + 1
newFstCell = "A" & newFstRow
ActiveSheet.Range(newFstCell) = TState
newScndCell = "B" & newFstRow
ActiveSheet.Range(newScndCell) = State
oXLRange.SpecialCells(xlCellTypeLastCell).Activate
newFstRow = oXLApp.ActiveCell.Row + 1
newFstCell = "A" & newFstRow
ActiveSheet.Range(newFstCell) = TPstCd
newScndCell = "B" & newFstRow
ActiveSheet.Range(newScndCell) = PstCd
oXLRange.SpecialCells(xlCellTypeLastCell).Activate
newFstRow = oXLApp.ActiveCell.Row + 1
newFstCell = "A" & newFstRow
ActiveSheet.Range(newFstCell) = TDtAndTime
newScndCell = "B" & newFstRow
ActiveSheet.Range(newScndCell) = DtAndTime
oXLSheet.Columns("A:C").ColumnWidth = 20
oXLSheet.Rows("1:6").RowHeight = 20
With oXLSheet.Columns("A")
.Font.Bold = True
.Font.Italic = True
.Font.ColorIndex = 25
.Font.Size = 13
End With
With oXLSheet.Columns("B")
.Font.ColorIndex = 50
.Font.Size = 10
End With
With oXLSheet.Columns("A:B")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
oXLApp.Visible = True
oXLBook.Close
oXLApp.Quit
Set oXLSheet = Nothing
Set oXLBook = Nothing
Set oXLApp = Nothing
End Sub
************************************************
Please someone help me to save the file without any mess
Thank u