Hi,
I'm trying to open an Excel sheet with VBA from within our fiance system.
My macro was working on my testmachine but now on a new machine I get a type mismatch error (error 13) on that line
For Each Cell In workbook.ActiveSheet.Range("A32:A202")
I think the way I create the Excel object is wrong?
Any help much appreciated.
I'm trying to open an Excel sheet with VBA from within our fiance system.
My macro was working on my testmachine but now on a new machine I get a type mismatch error (error 13) on that line
For Each Cell In workbook.ActiveSheet.Range("A32:A202")
I think the way I create the Excel object is wrong?
Any help much appreciated.
Code:
Dim workbooks As Excel.workbooks
Set workbook = CreateObject("Excel.Sheet")
workbook.Application.DisplayStatusBar = True
workbook.Application.Visible = True
workbook.Application.StatusBar = "Retrieving Currency Rates"
' Perform the actual internet query to retrieve the uptodate exchange rates.
With workbook.ActiveSheet.QueryTables.Add(Connection:= _
"URL;[URL unfurl="true"]http://www.xe.com/dfs/datafeed2.cgi",[/URL] Destination:=workbook.ActiveSheet.Range("A10"))
.FieldNames = False
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = False
.SaveData = True
End With
curTables(0) = "USD"
For Each curTable In curTables
CurTableFields("HOMECUR").Value = curTable
CurTableFields("RATETYPE").Value = rateType
CSTables.Read
CurRateFields("HOMECUR").Value = curTable
CurRateFields("RATETYPE").Value = rateType
>>>Error<<< For Each Cell In workbook.ActiveSheet.Range("A32:A202")
CurCodeFields("CURID").Value = Trim(Cell.Value)
....