如下MVBA代码能将当前文件的颜色表以RGB值的形式输出到指定的D:\ColorTableOutput.txt文件中。
Sub OutputColorTable() On Error GoTo FILEOPEN_ERROR Open "D:\ColorTableOutput.txt" For Output As #1 Dim ct As ColorTable Dim clr As Long, red As Long, green As Long, blue As Long Set ct = ActiveDesignFile.ExtractColorTable For i = 0 To 254 clr = ct.GetColorAtIndex(i): red = clr Mod &H100 clr = clr \ &H100: green = clr Mod &H100 clr = clr \ &H100: blue = clr Mod &H100 Print #1, "Color " & i & " - RGB " & red & "," & green & "," & blue Next clr = ct.BackColor: red = clr Mod &H100 clr = clr \ &H100: green = clr Mod &H100 clr = clr \ &H100: blue = clr Mod &H100 Print #1, "Color 255 - RGB " & red & "," & green & "," & blue Close #1 MsgBox "ColorTable exported to D:\ColorTableOutput.txt !" Exit Sub FILEOPEN_ERROR: MsgBox "File D:\ColorTableOutput.txt is in use" End Sub