I've got an Excel file that I'm trying to load information back to an ADT 2007 schedule called FKP_OpeningObjects. For some reason I get a run-time error '-2147467259 (80004005)':
Method 'Value' of object 'IAecScheduleProperty' failed
With options to click on OK or Help.
and the highlight yellow does not appear anywhere on a specific line item that is causing the error.
Using the VBA Manager - I have the following function that tries this called PullfromExcel...
Public Sub PullFromExcel()
'On Error GoTo Err_This
Dim i As Integer
Dim sFileName As String
sFileName = "C:\temp\test.xls"
Set oExcel = CreateObject("Excel.Applic
ation")
Set oXWorkbook = oExcel.Workbooks.Open(sFil
eName)
Set oXSheet = oXWorkbook.Worksheets(1)
Debug.Print oXSheet.Cells(1, 1)
oExcel.Visible = True
Dim ent As AcadEntity
Dim door As AecDoor
Dim schApp As New AecScheduleApplication
Dim cPropSets As AecSchedulePropertySets
Dim propSet As AecSchedulePropertySet
Dim cProps As AecScheduleProperties
Dim prop As AecScheduleProperty
i = 2
For Each ent In ThisDrawing.ModelSpace
If TypeOf ent Is AecDoor Then
Set door = ent
Set cPropSets = schApp.PropertySets(door)
Set propSet = cPropSets.Item("FKP_Openin
gObjects")
If Not propSet Is Nothing Then
Set cProps = propSet.Properties
i = i + 1
'cProps.Item("OpeningName"
).Value = oXSheet.Cells(i, 1)
'cProps.Item("OpeningNumbe
r").Value = oXSheet.Cells(i, 2)
'cProps.Item("SuffixNumber
").Value = oXSheet.Cells(i, 3)
'cProps.Item("DoorType").V
alue = oXSheet.Cells(i, 4)
'cProps.Item("OpeningMater
ial").Valu
e = oXSheet.Cells(i, 5)
'cProps.Item("FrameType").
Value = oXSheet.Cells(i, 6)
'cProps.Item("Material").V
alue = oXSheet.Cells(i, 7)
'cProps.Item("Hardware").V
alue = oXSheet.Cells(i, 8)
'cProps.Item("FireRating")
.Value = oXSheet.Cells(i, 9).Value
'cProps.Item("ElevationTyp
e").Value = oXSheet.Cells(i, 10)
'cProps.Item("TypicalRemar
ks").Value
= oXSheet.Cells(i, 11).Value
Debug.Print "Excel value: " '& the exact syntax code for the Excel value
Debug.Print " = AutoCAD value: " '& the exact syntax code for the AutoCAD value
Debug.Print
End If
End If
Next
Now the other set of code: PushtoExcel works the opposite (by taking the schedule and creating an Excel file) and works great without any problems. This allows me to create an Excel file based on the data in the AutoCAD schedule but I'm just scratching my head in how I can load back my new values to the AutoCAD schedule?
Public Sub PushToExcel()
Call CloseExcel
Set oExcel = CreateObject("Excel.Applic
ation")
Set oXWorkbook = oExcel.Workbooks.Add
Set oXSheet = oXWorkbook.Sheets(1)
oExcel.Visible = True
Dim ent As AcadEntity
Dim door As AecDoor
Dim schApp As New AecScheduleApplication
Dim cPropSets As AecSchedulePropertySets
Dim propSet As AecSchedulePropertySet
Dim cProps As AecScheduleProperties
Dim prop As AecScheduleProperty
Dim i As Integer
i = 1
oXSheet.Cells(1, 1).Value = "OpeningName"
oXSheet.Cells(1, 2).Value = "OpeningNumber"
oXSheet.Cells(1, 3).Value = "SuffixNumber"
oXSheet.Cells(1, 4).Value = "Size"
oXSheet.Cells(1, 5).Value = "DoorType"
oXSheet.Cells(1, 6).Value = "OpeningMaterial"
oXSheet.Cells(1, 7).Value = "FrameType"
oXSheet.Cells(1, 8).Value = "Material"
oXSheet.Cells(1, 9).Value = "Hardware"
oXSheet.Cells(1, 10).Value = "FireRating"
oXSheet.Cells(1, 11).Value = "ElevationType"
oXSheet.Cells(1, 12).Value = "TypicalRemarks"
oXSheet.Cells(1, 13).Value = "Object ID"
For Each ent In ThisDrawing.ModelSpace
If TypeOf ent Is AecDoor Then
Set door = ent
Set cPropSets = schApp.PropertySets(door)
Set propSet = cPropSets.Item("FKP_Openin
gObjects")
If Not propSet Is Nothing Then
Set cProps = propSet.Properties
i = i + 1
oXSheet.Cells(i, 1).Value = cProps.Item("OpeningName")
.Value
oXSheet.Cells(i, 2).Value = cProps.Item("OpeningNumber
").Value
oXSheet.Cells(i, 3).Value = cProps.Item("SuffixNumber"
).Value
oXSheet.Cells(i, 4).Value = cProps.Item("Size").Value
oXSheet.Cells(i, 5).Value = cProps.Item("Doortype").Va
lue
oXSheet.Cells(i, 6).Value = cProps.Item("OpeningMateri
al").Value
oXSheet.Cells(i, 7).Value = cProps.Item("FrameType").V
alue
oXSheet.Cells(i, 8).Value = cProps.Item("Material").Va
lue
oXSheet.Cells(i, 9).Value = cProps.Item("Hardware").Va
lue
oXSheet.Cells(i, 10).Value = cProps.Item("FireRating").
Value
oXSheet.Cells(i, 11).Value = cProps.Item("ElevationType
").Value
oXSheet.Cells(i, 12).Value = cProps.Item("TypicalRemark
s").Value
oXSheet.Cells(i, 13).Value = cProps.Item("ObjectID").Va
lue
End If
End If
Next
End Sub
Public Sub CloseExcel()
On Error Resume Next
Set oExcel = Nothing
Set oXWorkbook = Nothing
Set oXSheet = Nothing
End Sub
Start Free Trial