I am new to RB and interested in converting my VB application to RB.
I have been struggling with an application that reads an Excel
spreadsheet
and converts a worksheet into a CSV file so I can read each line into a
RealDatabase.
The code works great in VB but crashes (TypeMismatchError) in RB. I am
stumped. Any idea on what I am doing wrong?
I am using Realbasic 2006 v3 on WinXP, Excel 2000
Visual Basic code:
Dim Excel As Object
Dim book As Workbook
Dim sheet As Worksheet
' Routine that reads an EXCEL spreadsheet, converts it to CSV
Set Excel = CreateObject("Excel.Application")
strFilePath = App.Path & "\ update.txt"
Set book = Excel.Workbooks.Open(App.Path & "\sample spreadsheet.xls")
book.Sheets("Sheets1").Activate
Excel.DisplayAlerts = False
book.SaveAs strFilePath, 23
book.Close
Excel.Quit
Realbasic code:
dim excel as ExcelApplication
dim book as ExcelWorkbook
dim sheet as ExcelWorksheet
excel = new ExcelApplication
dim f as FolderItem
excel.DisplayAlerts = false
excel.Visible = false
f=GetFolderItem("")
book = excel.Workbooks.Open(f.AbsolutePath+"sample sheet.xls")
book.Sheets("Sheet1").activate
book.SaveAs(f.AbsolutePath + "temp1.csv" , 23) <------
TypeMismatchError
excel.book.close <------TypeMismatchError
excel.Quit
Regards,
Mark Bachurski
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>