(xlUp) problems then use in non excel

Joined
Dec 1, 2011
Messages
1
Reaction score
0
Hi! I need your help with an Runtime error I have.
Then I tried a code in Excel-VBA it works perfekt. But then execute hte code in Catia-VBA to do same thin in Excel i got runtime error.
Does anyone have an idea?
/RS

Here is the code i write in EXCEL-VBA
Code:
Sub ReadWriteExcel()
StrActiveCell = Range("A65536").End(xlUp).Select
StrValue = ActiveCell.Value
Debug.Print ActiveCell.Row
Range("A" & ActiveCell.Row + 1).Select
ActiveCell.FormulaR1C1 = StrValue + 5
End Sub

Here is the code I write in Catia-VBA
Code:
Sub ReadWriteExcel()
Dim WshShell
Dim objXlsSheet As Object
Dim strFileName As String
Dim objExcel, objWorkbook, ExcelFile, workbooks
Dim StrRow, cellen, xldown, range, StrValue, StrActiveCell, xlUp
Set WshShell = CreateObject("wscript.shell")
    ExcelFile = ("C:\temp\drwnr.xls ")
    strFileName = ExcelFile
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.workbooks.Open (strFileName)
Set objWorkbook = objExcel.activeworkbook
Set objXlsSheet = objExcel.ActiveSheet
 
StrActiveCell = objXlsSheet.range("B65536").End(xlUp).Select  '<<--- here I recieved the error: Run-time error '1004:' Application-Defined or object-defined error.

StrValue = objXlsSheet.ActiveCell.Value
Debug.Print objXlsSheet.ActiveCell.Row
range("B" & objXlsSheet.ActiveCell.Row + 1).Select

objExcel.displayalerts = False
objWorkbook.SaveAs ("C:\temp\drwnr.xls ")
objWorkbook.Close False
objExcel.Quit
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top