-
Notifications
You must be signed in to change notification settings - Fork 576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run-time error '458' after migrating to 64-bit Office #243
Comments
In your Workaround is the answer to why you are experiencing what you are. The Second your code in the Dim song as Scripting.Dictionary ' Add reference, VBA Editor Tools->Reference, search for Microsoft Scripting Runtime.
For Each song In json
ws.Cells(nRow, 1) = VBA.IIF( song.Exists("artist"), song.Item("artist"), VBA.CVErr(Excel.XlCVError.xlErrValue))
ws.Cells(nRow, 2) = VBA.IIF( song.Exists("title"), song.Item("title"), VBA.CVErr(Excel.XlCVError.xlErrValue))
nRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1
Next song Lastly you might want to consider making the area in your worksheet a table, then use the Excel Option Explicit
Sub BugRepro()
Dim strJson As String
Dim json As VBA.Collection
Dim song As Scripting.Dictionary
Dim ws As Worksheet
Dim tbl As ListObject
Dim col As ListColumns
Dim row As ListRow
strJson = "[{""artist"":""Ray Charles"",""title"":""Mess Around""},{""artist"":""Ratt"",""title"":""Lay It Down""}]"
Set json = JsonConverter.ParseJson(strJson)
Set ws = ThisWorkbook.Sheets("Sheet1")
Set tbl = ws.ListObjects("Table1")
Set col = tbl.ListColumns
For Each song In json
Set row = tbl.ListRows.Add
row.Range(, col("Artist").Index) = VBA.IIf(song.Exists("artist"), song.Item("artist"), VBA.CVErr(Excel.XlCVError.xlErrValue))
row.Range(, col("Title").Index) = VBA.IIf(song.Exists("title"), song.Item("title"), VBA.CVErr(Excel.XlCVError.xlErrValue))
Next song
Exit Sub
End Sub |
Problem
After migrating from 32-bit to 64-bit Office, macro throws run-time error '458': Variable uses an Automation type not supported in Visual Basic.
Environment
Microsoft 365 64-bit Version 2210
Windows 11 22H2
Repro Steps
Actual Results
Throws error
Microsoft Visual Basic
Run-time error '458':
Variable uses an Automation type not supported in Visual Basic
Expected Results
Sheet1 is populated with data
Workaround
Rename this line in Module1.BugRepro
Dim song As Variant
to
Dim song As Object
Changing the data type from Variant to Object works.
Debugging
When I click the Debug button of the error message and press F8 to step into the code it goes into line 65 of Dictionary class module
Public Property Get item(key As Variant) As Variant
Keep pressing F8 until it gets to line 86,
End Property
press F8 it throws the error.The text was updated successfully, but these errors were encountered: