Application-defined Or Object-defined Error When Reopening
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About application defined or object defined error excel Us Learn more about Stack Overflow the company Business Learn more about hiring
Application Defined Or Object Defined Error Access
developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the application defined or object defined error 32809 Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up VBA Runtime Error 1004 “Application-defined or
Application Defined Or Object Defined Error In Macro
Object-defined error” up vote 1 down vote favorite I have code VBA code written in MS Access 2010 (.mbd file) to write data into an Excel file (.xls file). Below is the code to write data into that excel file. When you run this code, it always throws Error#1004 "Application-defined or Object-defined error". When you debug the code (F8) or run it (F5), it runs absolutely fine application defined or object defined error in vba with out any issues. I am still not able to figure it out on what exactly the issue is. This code works fine when executed in MS Access 2007. Below is thr code that's getting executed and when it fails, the focus is set on the 3rd last line of the code marked in double astriek mark. Sub PopulateReport(appExcel As Object, testcam) Dim Site As String, intRec As Integer, i As Integer, cnt As Integer, intRecSet As Integer, cntr As Integer Dim F1 As String, F2 As String, F3 As String, F4 As String, F5 As String, F6 As String, F7 As String Dim F8 As String, F9 As String, F10 As String, F11 As String, F12 As String, F13 As String, CAMDate As Date Close i = 0 cnt = 0 cntr = 0 Set cnn = CurrentProject.Connection rec.Open "SELECT * FROM Site", cnn, adOpenStatic, adLockPessimistic rec.MoveLast rec.MoveFirst intRec = rec.RecordCount Do Until cnt = intRec rec.MoveLast rec.MoveFirst rec.Move cnt Site = rec(4) Select Case Site Case "Fort Worth" cntr = 0 recset.Open "SELECT * FROM Employee", cnn, adOpenStatic, adLockPessimistic recset.MoveLast recset.MoveFirst intRecSet = recset.RecordCount appExcel.Application.Goto Reference:="START_FW_CL" Do Until cntr = intRecSet - 1 appExcel.Selection.EntireRow.Copy appExcel.Selection
be down. Please try the request again. Your cache administrator is webmaster. Generated Fri, 30 Sep 2016 15:04:17 GMT by s_hv972 (squid/3.5.20)
in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that http://forum.chandoo.org/threads/run-time-error-1004-application-defined-or-object-defined-error.21327/ we have people here for whom English is not there first language and we need to allow for this in our dealings. Yours, Chandoo Hi All Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam Post Spam and you Will Be Deleted as a User Hui... When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post. Welcome Message to New users defined or Spam Sample File Run time error 1004: Application defined or Object-Defined Error. Discussion in 'VBA Macros' started by Jagdev Singh, Jan 15, 2015. Jagdev Singh Active Member Messages: 594 Hi Experts, I am getting 1004 error in the following code: in the Do Statement. Could you please lemme know what am I missing here. Do While objSh.Cells(irow, 1) <> "Report Total (s) EUR" If (objSh.Cells(irow, 4) = "Complete" Or objSh.Cells(irow, 4) = "UnPaid" Or objSh.Cells(irow, 4) = defined or object "Part Paid" Or objSh.Cells(irow, 4) = "Paid") Then objOut.Cells(iTgtRow, 1) = objSh.Cells(irow, 1) ' objOut.Cells(iTgtRow, 2) = strCCode 'objOut.Cells(iTgtRow, 3) = strCName 'objOut.Cells(iTgtRow, 4) = strCurrancy 'If (objSh.Cells(irow, 5)) = "C00002240" Then ' MsgBox "I am here" 'End If objOut.Cells(iTgtRow, 5) = objSh.Cells(irow, 5) objOut.Cells(iTgtRow, 6) = objSh.Cells(irow, 6) Strdate = objSh.Cells(irow, 7) objOut.Cells(iTgtRow, 7) = GetDateValue(Strdate) strAmt = objSh.Cells(irow, 8) ' If InStr(strAmt, "(") > 0 Then ' isNegative = True ' End If strAmt = Replace(strAmt, ".", "") strAmt = Replace(strAmt, "(", "") strAmt = Replace(strAmt, ")", "") strAmt = Replace(strAmt, ",", ".") objOut.Cells(iTgtRow, 8) = Val(strAmt) strAmt = objSh.Cells(irow, 9) strAmt = Replace(strAmt, ".", "") strAmt = Replace(strAmt, "(", "") strAmt = Replace(strAmt, ")", "") strAmt = Replace(strAmt, ",", ".") objOut.Cells(iTgtRow, 9) = Val(strAmt) * -1 objOut.Cells(iTgtRow, 10) = "Third Party" iTgtRow = iTgtRow + 1 irow = irow + 1 Else irow = irow + 1 End If Loop Regards, JD Jagdev Singh, Jan 15, 2015 #1 NARAYANK991 Excel Ninja Messages: 13,995 Hi Jaggi , This is something you can troubleshoot yourself. When the error message is displayed , I assume the Debug button is available ; click on it , and in the Immediate window , type in all of the following , to get as much information as possible : ?irow ?objSh.Name ?objSh.Cells(irow,1).Address ?objSh.Cells(irow,1).Value If the last line displays something like Error 204