realbasic-nug
[Top] [All Lists]

Excel automation issues

To: realbasic-nug at lists dot realsoftware dot com
Subject: Excel automation issues
From: Mark Bachurski <mark at bachurski dot net>
Date: Mon, 31 Jul 2006 16:40:49 -0400
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
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>


<Prev in Thread] Current Thread [Next in Thread>
  • Excel automation issues, Mark Bachurski <=