Error Trying to Display The Names of All Excel Data Models in a Workbook

0 votes

In my workbook, I'm attempting to display the names of my DataModels. I defined model as an object in the next line of code.

For Each model In ThisWorkbook.model.WorkbookDataModels

The message "Object doesn't support this property or function" appears to me.

I've confirmed that the references section has the Microsoft Excel 16.0 Object Library checked. I work using Excel 365. Why am I mishandling this? I appreciate any help you can give.

Here is the code:

Sub ShowDataModels()
    Dim model As Object
    Dim tbl As Object
    Dim rel As Object
    
    For Each model In ThisWorkbook.model.WorkbookDataModels
        Debug.Print "Data Model Name: " & model.ModelName
        Debug.Print "  Tables:"
        
        For Each tbl In model.ModelTables
            Debug.Print "    " & tbl.Name
        Next tbl
        
        Debug.Print "  Relationships:"
        
        For Each rel In model.ModelRelationships
            Debug.Print "    " & rel.FromTable.Name & " -> " & rel.ToTable.Name
        Next rel
    Next model
End Sub
Apr 10, 2023 in Others by narikkadan
• 63,600 points
469 views

1 answer to this question.

0 votes
It is necessary to list ThisWorkbook.model. Not WorkbookDataModels, but ModelTables. I believe you might be confusing the idea of the overall model with all of its components.

There is only one DataModel, which may contain many tables, in an Excel workbook.
answered Apr 10, 2023 by Kithuzzz
• 38,000 points

Related Questions In Others

0 votes
1 answer
0 votes
1 answer

How can I store the data of an open excel workbook in a collection using BluePrism?

To do what you want is like ...READ MORE

answered Nov 24, 2022 in Others by narikkadan
• 63,600 points
1,365 views
0 votes
1 answer

In a excel formula I need to create a list of names on one sheet based upon criteria/data of another sheet

The final formula is: =IF(ROWS($H$3:H3)<=$I$1,INDEX(Personnel! ...READ MORE

answered Nov 25, 2022 in Others by narikkadan
• 63,600 points
1,105 views
0 votes
1 answer

Excel: Is it possible to reorder the data in 2 columns to match up if they have a certain number of characters / a string in common?

Try this: =LET(files,A1:A4, URLs,B1:B4, f,BYROW(files,LAMBDA(r,TEX ...READ MORE

answered Jan 21, 2023 in Others by narikkadan
• 63,600 points
586 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,215 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,668 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
912 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
1,057 views
0 votes
1 answer

Excel VBA- How to loop through specific sheets in a workbook and format the same ranges in each sheet

Range(...) instructs VBA to always use the ...READ MORE

answered Mar 21, 2023 in Others by Kithuzzz
• 38,000 points
1,763 views
0 votes
1 answer

How to automatically assign a color to the maximum and minimum values in a set of selected cells in Excel?

See Conditional Formatting, which may be accessed ...READ MORE

answered Apr 7, 2023 in Others by Kithuzzz
• 38,000 points
545 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP