以下子句枚举了活动工作表的shapes集合的有趣属性,当包含Case msoIgxGraphic时,不会对其进行编译。尽管我发誓它确实在今天早些时候进行了编译。我正在使用Excel2007。msoShapeType Enumeration defined for Office 2007显然包含该值。

我检查并再次检查是否存在拼写错误-找不到一个。

我仅将一个子添加到新创建的工作簿(否则为空)的模块中。仍然不会编译。错误消息是:

'Compile Error: Variable not Defined'


并且msoIgxGraphic突出显示。用select语句注释该节,然后编译并运行它,没问题。我想念什么?

    Option Explicit

    Sub GetShapeProperties()

        Dim sShapes As Shape, lLoop As Long
        Dim wsStart As Worksheet, WsNew As Worksheet
        Dim obj As OLEObject
        Dim obType As String

        ''''''''''''''''''''''''''''''''''''''''''''''''
        ''''''''''LIST PROPERTIES OF SHAPES'''''''''''''
        ''''''''''Dave Hawley www.ozgrid.com''''''''''''
        ''''''''''''''''''''''''''''''''''''''''''''''''

        Set wsStart = ActiveSheet
        Set WsNew = Sheets.Add

        If Len("Shapes Info") <> 0 Then
           Application.DisplayAlerts = False
           On Error Resume Next
           Worksheets("Shapes Info").Delete
           On Error GoTo 0
           Application.DisplayAlerts = True
           WsNew.Name = "Shapes Info"
        End If

        'Add headings for our lists. Expand as needed

        WsNew.Range("A1:X1") = _
         Array("Shape Name", ".OLEFormat.Object.Name", "Height", "Width", "Left", "Top" _
    , "AlternativeText" _
    , "Id" _
    , "Type" _
    , "Shape Type" _
    , "OLEFormat.Object.index" _
    , "OLEFormat.Object.Left" _
    , "OLEFormat.Object.Width" _
    , "OLEFormat.Object.Top" _
    , "OLEFormat.Object.Height" _
    , "OLEFormat.Object.TopLeftCell.Address" _
    , "OLEFormat.Object.BottomRightCell.Address" _
    , "OLEFormat.Object.ZOrder" _
    , "OLEFormat.Object.Locked" _
    , "OLEFormat.Object.Visible" _
    , "OnAction" _
    , "VerticalFlip" _
    , "ZOrderPosition")

        'Loop through all shapes on active sheet

        For Each sShapes In wsStart.Shapes

      'Increment Variable lLoop for row numbers

      lLoop = lLoop + 1

      With sShapes

          'Add shape properties

          WsNew.Cells(lLoop + 1, 1) = .Name
          WsNew.Cells(lLoop + 1, 2) = .OLEFormat.Object.Name
          WsNew.Cells(lLoop + 1, 3) = .Height
          WsNew.Cells(lLoop + 1, 4) = .Width
          WsNew.Cells(lLoop + 1, 5) = .Left
          WsNew.Cells(lLoop + 1, 6) = .Top
          'Follow the same pattern for more
          WsNew.Cells(lLoop + 1, 7) = .AlternativeText
          WsNew.Cells(lLoop + 1, 8) = .ID
          WsNew.Cells(lLoop + 1, 9) = .Type
          Select Case .Type
           Case msoAutoShape
            obType = "AutoShape"
           Case msoCallout
            obType = "Callout"
           Case msoCanvas
            obType = "Canvas"
           Case msoChart
            obType = "Chart"
           Case msoComment
            obType = "Comment"
           Case msoDiagram
            obType = "Diagram"
           Case msoEmbeddedOLEObject
            obType = "EmbeddedOLEObject"
           Case msoFormControl
             Select Case .FormsControlType
                Case xlButtonControl
                    obType = "FormsControlType Button"
                Case xlCheckBox
                    obType = "FormsControlType CheckBox"
                Case xlDropDown
                    obType = "FormsControlType DropDown"
                Case xlEditBox
                    obType = "FormsControlType EditBox"
                Case xlGroupBox
                    obType = "FormsControlType GroupBox"
                Case xlLabel
                    obType = "FormsControlType Label"
                Case xlListBox
                    obType = "FormsControlType ListBox"
                Case xlOptionButton
                    obType = "FormsControlType OptionButton"
                Case xlScrollBar
                    obType = "FormsControlType ScrollBar"
                Case xlSpinner
                    obType = "FormsControlType Spinner"
                Case Else
                    obType = "Unknown MsoFormsControlType"
              End Select
           Case msoFreeform
            obType = "Freeform"
           Case msoGroup
            obType = "Group"
           Case msoIgxGraphic
            obType = "IgxGraphic"
           Case msoInk
            obType = "Ink"
           Case msoInkComment
            obType = "InkComment"
           Case msoLine
            obType = "Line"
           Case msoLinkedOLEObject
            obType = "LinkedOLEObject"
           Case msoLinkedPicture
            obType = "LinkedPicture"
           Case msoMedia
            obType = "Media"
           Case msoOLEControlObject
            Set obj = .OLEFormat.Object
            obType = "OLEControlObject " + "(" + obj.Application.Name + "): " + TypeName(obj.Object)
           Case msoPicture
            obType = "Picture"
           Case msoPlaceholder
            obType = "Placeholder"
           Case msoScriptAnchor
            obType = "ScriptAnchor"
           Case msoShapeTypeMixed
            obType = "ShapeTypeMixed"
           Case msoTable
            obType = "Table"
           Case msoTextBox
            obType = "TextBox"
           Case msoTextEffect
            obType = "TextEffect"
           Case Else
            obType = "Unknown MsoShapeType"
        End Select
        WsNew.Cells(lLoop + 1, 10) = obType

        WsNew.Cells(lLoop + 1, 12) = .OLEFormat.Object.Index
          WsNew.Cells(lLoop + 1, 13) = .OLEFormat.Object.Left
          WsNew.Cells(lLoop + 1, 14) = .OLEFormat.Object.Width
          WsNew.Cells(lLoop + 1, 15) = .OLEFormat.Object.Top
          WsNew.Cells(lLoop + 1, 16) = .OLEFormat.Object.Height
          WsNew.Cells(lLoop + 1, 17) = .OLEFormat.Object.TopLeftCell.Address
          WsNew.Cells(lLoop + 1, 18) = .OLEFormat.Object.BottomRightCell.Address
          WsNew.Cells(lLoop + 1, 19) = .OLEFormat.Object.ZOrder
          WsNew.Cells(lLoop + 1, 20) = .OLEFormat.Object.Locked
          WsNew.Cells(lLoop + 1, 21) = .OLEFormat.Object.Visible
          WsNew.Cells(lLoop + 1, 22) = .OnAction
          WsNew.Cells(lLoop + 1, 24) = .VerticalFlip
          WsNew.Cells(lLoop + 1, 25) = .ZOrderPosition

      End With

      Next sShapes
      WsNew.Columns.AutoFit

    End Sub

最佳答案

当我使用对象浏览器查看MsoShapeType枚举时,似乎msoIgxGraphic被替换为msoSmartArt

我最好的猜测是,此更改是Windows \ Office更新的一部分。您知道在它工作到失败之间是否应用了任何更新吗?

09-11 02:13