473,405 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Getting error "Application defined or object defined error"

Hi all
I am trying to create a database using vb6 and excel
I created few controls on the vb form and coded to get the details from the user
I code in the way to pass the data which i got from the user to an excel sheet
I named a function in a module as "Appending" and i made it to receive all the data through arguments
And almost I coded correctly to make the database look in the format i need

Eveeything is OK,but when I am running the program I am getting "Application defined or object defined error"..

This is the line where i am getting the error
******************************
NextToBlankRow = ActiveSheet.Range(BlankRowCell).End(xlDown).Offset (1, 0).Row
**********************************

As I am in the learning phase of VB6, I am not sure where I am going wrong

Please look at my code below and help me out in this

This is the module where i made the procedure to accept all the values from the vb form and to save it in an excel file in the format i need

MY CODE SNIPPET
************************************************** *****

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
Apr 22 '12 #1
0 1618

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Al | last post by:
Hi, I am getting "Application-defined or object-define error" when trying to instantiate an MTS component. However, when I run the VB source-code and leave it in run-time, I am able to...
3
by: Dmitry | last post by:
Hi, I have defined interface for COM components which inludes an argument being filled with additional error info, if such occurs. If inside I raise COM Error, I populate that parameter. In COM...
2
by: Boniek | last post by:
Hi, How I can create property to binding with other objects. I want to create a data object which work as a DataTable. DataTable contains columns and dataTable is used to binding with a textBox...
2
by: news.microsoft.com | last post by:
hi, I am new in ASP.NET i make a page using Visual Studio.net compile and successfully run on local system but when i upload it on my internet live server it always gives me the same error if...
1
by: Dave | last post by:
I'm getting the following error on an EditCommand event. This code is running on production web farm and the thing is it doesn't happen all the time. If I get this error, click the back button,...
1
by: Samuel R. Neff | last post by:
Occasionally we get this error message when running an app on a test machine: .exe - Common Language Runtime Debugging Services Application has generated an exception that could not be...
4
by: JackBlack | last post by:
Hi, all! Need a little help tracking down a runtime error problem. I'm getting this error: "Unable to cast object of type 'myStruct' to type 'myStruct'... but the two types are identical! I...
2
by: Ian Boyd | last post by:
We're encountering a situation where we're encountering a deadlock, and someone's been made the deadlock victim. But after that, DB2 refuses to run any SQL, and instead we get the error message: ...
0
by: =?Utf-8?B?SkhhbGV5?= | last post by:
Our system is: IIS Server: dual Intel Xeon 2.80 GHz, 4 GB Ram Windows Server 2003 SP2 IIS 6.0 SQL Server: dual Intel Xeon 2.80 GHz, 4 GB Ram (separate server) Windows Server 2003 SP2 SQL...
1
by: Wiinie | last post by:
Hi all, I am new bird using Ruby, I just occur the problem "uninitialized constant Object::Person (NameError)" can any experts help me? my code is class Person def initialize(fname,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.