ไปยังเนื้อหาหลัก

วิธีแสดงรายการคุณสมบัติของไฟล์ Excel ทั้งหมดในแผ่นงาน

ในบทความนี้ฉันแนะนำรหัส VBA เพื่อแสดงรายการคุณสมบัติทั้งหมดของสมุดงานที่ใช้งานอยู่ในแผ่นงาน

1 กด Alt + F11 คีย์เพื่อเปิดใช้งานหน้าต่าง Microsoft Visual Basic for Applications

2 คลิก สิ่งที่ใส่เข้าไป > โมดูลและวางโค้ดด้านล่างลงในโมดูลเปล่า

VBA: แสดงรายการคุณสมบัติทั้งหมด

Sub WBProperties()
'UpdatebyKutools20191031
    Dim xWB As Workbook
    Dim xF As Long
    Dim xStr As String
    Dim xWSh As Worksheet
    On Error Resume Next
    Application.DisplayAlerts = False
    xStr = "Workbook Properties"
    Set xWB = Application.ActiveWorkbook
    Set xWSh = xWB.Worksheets.Item(xStr)
    If Not xWSh Is Nothing Then
        xWSh.Delete
    End If
    Set xWSh = xWB.Worksheets.Add
    xWSh.Name = xStr
    xWSh.Range("A1").Value = "Property"
    xWSh.Range("B1").Value = "Value"
    With xWB
        For xF = 1 To .BuiltinDocumentProperties.Count
            xWSh.Range("A65536").End(xlUp).Offset(1, 0).Value = _
            .BuiltinDocumentProperties.Item(xF).Name
            xWSh.Range("A65536").End(xlUp).Offset(0, 1).Value = _
            .BuiltinDocumentProperties.Item(xF).Value
        Next xF
    End With
    Application.DisplayAlerts = True
End Sub

doc แสดงรายการทั้งหมดเพิ่มใน 1

3 กด F5 คีย์ในการรันโค้ดแผ่นงานใหม่ชื่อ Workbook Properties ได้ถูกสร้างขึ้นที่ด้านหน้าของแผ่นงานที่ใช้งานอยู่ซึ่งแสดงรายการคุณสมบัติทั้งหมดของสมุดงานที่ใช้งานอยู่
doc แสดงรายการทั้งหมดเพิ่มใน 1


การดำเนินงานอื่น ๆ (บทความ)

ปิดการใช้งาน Add-in เมื่อเริ่มต้น Excel
คุณอาจติดตั้ง Add-in ไว้ใน Microsoft Excel แล้ว แต่ตอนนี้คุณต้องปิดใช้งาน Add-in ที่ระบุเมื่อเริ่มต้น Excel จะแก้ปัญหานี้อย่างไร? วิธีการในบทความนี้สามารถช่วยคุณได้

ส่งออกและบันทึกแต่ละแผ่นงานเป็นสมุดงานใหม่แยกกันใน Excel
สมมติว่าคุณต้องการส่งออกและบันทึกแผ่นงานหนึ่งหรือหลายแผ่นเป็นสมุดงานใหม่คุณจะจัดการกับมันอย่างไร? โดยปกติคุณสามารถคัดลอกแผ่นงานแต่ละแผ่นและวางลงในสมุดงานใหม่ได้ แต่ที่นี่เรานำเสนอเคล็ดลับที่มีประโยชน์เพื่อจัดการกับมัน:

รหัส VBA เพื่อแสดงรายการเพิ่มเติมทั้งหมดใน Excel
ใน Excel คุณสามารถเพิ่มหรือแทรกข้อมูลเพิ่มเติมเพื่อให้จัดการกับข้อมูลได้ดีขึ้น ดังที่เราทราบเราสามารถไปที่หน้าต่างตัวเลือกเพื่อดูข้อมูลเพิ่มเติมทั้งหมด แต่มีวิธีใดในการแสดงรายการเพิ่มเติมทั้งหมดในแผ่นงานหรือไม่?


เครื่องมือเพิ่มประสิทธิภาพการทำงานในสำนักงานที่ดีที่สุด

Kutools สำหรับ Excel แก้ปัญหาส่วนใหญ่ของคุณและเพิ่มผลผลิตของคุณได้ถึง 80%

  • ซุปเปอร์ฟอร์มูล่าบาร์ (แก้ไขข้อความและสูตรหลายบรรทัดได้อย่างง่ายดาย); การอ่านเค้าโครง (อ่านและแก้ไขเซลล์จำนวนมากได้อย่างง่ายดาย); วางลงในช่วงที่กรองแล้ว...
  • ผสานเซลล์ / แถว / คอลัมน์ และการเก็บรักษาข้อมูล แยกเนื้อหาของเซลล์ รวมแถวที่ซ้ำกันและผลรวม / ค่าเฉลี่ย... ป้องกันเซลล์ซ้ำ; เปรียบเทียบช่วง...
  • เลือกซ้ำหรือไม่ซ้ำ แถว; เลือกแถวว่าง (เซลล์ทั้งหมดว่างเปล่า); Super Find และ Fuzzy Find ในสมุดงานจำนวนมาก สุ่มเลือก ...
  • สำเนาถูกต้อง หลายเซลล์โดยไม่เปลี่ยนการอ้างอิงสูตร สร้างการอ้างอิงอัตโนมัติ ถึงหลายแผ่น ใส่สัญลักษณ์แสดงหัวข้อย่อย, กล่องกาเครื่องหมายและอื่น ๆ ...
  • แทรกสูตรที่ชื่นชอบและรวดเร็ว, ช่วงแผนภูมิและรูปภาพ; เข้ารหัสเซลล์ ด้วยรหัสผ่าน; สร้างรายชื่อผู้รับจดหมาย และส่งอีเมล ...
  • แยกข้อความ, เพิ่มข้อความ, ลบตามตำแหน่ง, ลบ Space; สร้างและพิมพ์ผลรวมย่อยของเพจ แปลงระหว่างเนื้อหาของเซลล์และความคิดเห็น...
  • ซุปเปอร์ฟิลเตอร์ (บันทึกและใช้โครงร่างตัวกรองกับแผ่นงานอื่น ๆ ); การเรียงลำดับขั้นสูง ตามเดือน / สัปดาห์ / วันความถี่และอื่น ๆ ตัวกรองพิเศษ โดยตัวหนาตัวเอียง ...
  • รวมสมุดงานและแผ่นงาน; ผสานตารางตามคอลัมน์สำคัญ แยกข้อมูลออกเป็นหลายแผ่น; Batch แปลง xls, xlsx และ PDF...
  • การจัดกลุ่มตาราง Pivot ตาม จำนวนสัปดาห์วันในสัปดาห์และอื่น ๆ ... แสดงปลดล็อกเซลล์ที่ถูกล็อก ด้วยสีที่ต่างกัน เน้นเซลล์ที่มีสูตร / ชื่อ...
kte แท็บ 201905
  • เปิดใช้งานการแก้ไขและอ่านแบบแท็บใน Word, Excel, PowerPoint, ผู้จัดพิมพ์, Access, Visio และโครงการ
  • เปิดและสร้างเอกสารหลายรายการในแท็บใหม่ของหน้าต่างเดียวกันแทนที่จะเป็นในหน้าต่างใหม่
  • เพิ่มประสิทธิภาพการทำงานของคุณ 50% และลดการคลิกเมาส์หลายร้อยครั้งให้คุณทุกวัน!
ด้านล่าง officetab
Comments (1)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello,

First off, I do not know VBA, but have determined after hours of searching, it is the only solution to my problem.

Background:
I have a workbook with a large number of Power Query-created "Merge"-type Queries and Queries that pull data from flat files; some, but not all are added to the Data Model/Power Pivot.

The composition of queries may change over time.

Within a subset of the queries, I have disabled refreshing with "Refresh All" to reduce the already lengthy time it takes to refresh all queries.

There are a large number of worksheets that contain Pivots off the Data Model, whereas the others contain a subset of tables that are populated from the queries via "Load To"

I am using O365 Excel

The example code below is based on hours of research. I don't know if it's of value in achieving my objectives below, but I'm including it in the event it sparks a solution.

Objectives:
I would like an "index" worksheet created containing a dynamic table (or just listed out in cells that I can convert to a table manually) that keeps an up-to-date list of workbook "Query-" queries and their respective properties below.

The dynamic (e.g., reflect added/changed/deleted queries) table should contain the following columns with the following query/connection properties as fields:
-----------------------------------------------------
"Name", "Description", "RefreshWithRefreshAll", "InModel", "Type"

The following example is what I was able to cobble together from the interwebs which got me some of the way there, but it only allows me to see it in the VBA Immediate window, and I don't know how to get it into a table on the worksheet:

Sub ListConnections()

Dim cn As WorkbookConnection

Debug.Print "Name", "|", "Description", "|", "|", "RefreshWithRefreshAll", "|", "InModel", "|", "Type"


For Each cn In ThisWorkbook.Connections
Debug.Print cn.Name, "|", cn.Description, "|", cn.RefreshWithRefreshAll, "|", cn.InModel, "|", cn.Type

Next
End Sub-----------------------------------------------------

Currently, I can only get it to output in the Immediate Window:
-----------------------------------------------------
Name|Description||RefreshWithRefreshAll|InModel|Type
ModelConnection_ExternalData_1|DataModel|True|True|7
ModelConnection_ExternalData_11|DataModel|True|True|7
Query-AllADMembers(CX)|Connectiontothe'AllADMembers(CX)'queryintheworkbook.|True|True|1
Query-AllAzureADUsers-Disabled|Connectiontothe'AllAzureADUsers-Disabled'queryintheworkbook.|True|False|1
Query-AllAzureADUsers-Enabled|Connectiontothe'AllAzureADUsers-Enabled'queryintheworkbook.|True|False|1
Query-AllAzureADUsersOnly|Connectiontothe'AllAzureADUsersOnly'queryintheworkbook.|True|False|1
...

Query-UsersinDA,NotinApp-BulkDEL*|Connectiontothe'UsersinDA,NotinApp-BulkDEL*'queryintheworkbook.|False|True|1
ThisWorkbookDataModel|DataModel|True|True|7
-----------------------------------------------------
Note 1: I used the convention of adding an asterisk to the query name to visually see which queries I disabled refreshing with Refresh All.
Note 2: Query names with (CNX) refer to the base queries to the flat files upon which the other merge queries are based.
Note 3: The "Last Refresh" field in the table would be the Date/Time of the Last Refresh of the query. I was hoping it could be obtained as a property of the query, since this timestamp is shown when hovering over the query in the query pane, e.g.

<br style="letter-spacing: 0.2px;">
Based on my searches, it does not appear that this is obtainable for some reason, but if not, I found other references to adding it as a calculated value using timestamps of macro executed refreshes.

Example: I found many references to adding a button to have a macro refresh one or refresh all queries. My thought is that one could create code to dynamically enumerate the names from the code above Query-[Query Name], then have the code execute a refresh of each (CNX) query above first, then execute the rest individually to capture the execution and/or finish timestamp. Since there is a natural sequence that Excel uses when doing a refresh all, executing queries manually may trigger the natural sequence multiple times making the overall refresh times unbearable. Looking for the most efficient solution here.

Here is some code that I thought would be useful to tackle this, but again, it only shows output in the Immediate Window when executed.
-----------------------------------------------------
Dim TStart As Date
Dim TEnd As Date
Dim cn As WorkbookConnection

For Each cn In ThisWorkbook.Connections

If Left(cn, 13) = "Power Query -" Then
Debug.Print cn
TStart = Now
cn.Refresh
TEnd = Now
Debug.Print CStr(DateDiff("s", TStart, TEnd)) + " Seconds"
Debug.Print ""

End If
Next cn
End Sub
-----------------------------------------------------
Thanks in advance!

M
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations