wsnyder
Board Regular
- Joined
- Sep 23, 2018
- Messages
- 226
- Office Version
- 365
- Platform
- Windows
Hi all,
Has anyone tried to use the Objects of the Model Object (Data Model aka Power Pivot)?
I am trying to get a few Properties of the ModelRelationship Object, but I keep getting an error:
code snippet:
I tried both looping the collection and by index number, but I get the same error either way.
Thanks
w
Has anyone tried to use the Objects of the Model Object (Data Model aka Power Pivot)?
I am trying to get a few Properties of the ModelRelationship Object, but I keep getting an error:
Run-time error '1004':
Application-defined or object-defined error
code snippet:
VBA Code:
Dim dm As Model
Dim dmr As ModelRelationship
For Each dmr In .ModelRelationships
wsnew.Cells(j, 1).Value = dmr.PrimaryKeyTable
wsnew.Cells(j, 2).Value = dmr.PrimaryKeyColumn
wsnew.Cells(j, 3).Value = dmr.ForeignKeyTable
wsnew.Cells(j, 4).Value = dmr.ForeignKeyColumn
j = j + 1
Next dmr
' With dm
' i = .ModelRelationships.Count
' Debug.Print "Relationship Count: " & i
' j = GetRows(ws:=wsnew) + 1
' For x = 1 To i
' wsnew.Cells(j, 1).Value = .ModelRelationships(x).PrimaryKeyTable
' wsnew.Cells(j, 2).Value = .ModelRelationships(x).PrimaryKeyColumn
' wsnew.Cells(j, 3).Value = .ModelRelationships(x).ForeignKeyTable
' wsnew.Cells(j, 4).Value = .ModelRelationships(x).ForeignKeyColumn
' j = j + 1
' Next x
' End With
I tried both looping the collection and by index number, but I get the same error either way.
Thanks
w