我已经在 vba 中开发了一些代码来检测不同类型的形状、创建和压缩文件等等......问题是现在我必须在 Visual Studio 2012 中创建一个功能区项目并制作一个按钮我在 vba 中所做的事情。我创建了功能区,向其添加了一个按钮并将我必须的代码添加到该按钮,但它有很多错误,例如在我拥有 ActivePresentation 的所有行中。有什么方法可以在 VS 中使用我在 VBA 中使用的不同对象?否则有人知道我可以用什么代替吗?
我的代码太长了......这里有一小部分可以让我了解我在做什么:
Dim sNum As Integer
Dim stri As String
Dim i, j As Integer
Dim right As Boolean
Dim value As MsoShapeType
Dim it As String
right = True
k = 0
j = 0
it = "Cannot convert the file due to the following problems:" & vbNewLine & vbNewLine
'ActivePresentation.Slides(1).Shapes(1).
For Each sld In ActivePresentation.Slides
For i = 1 To sld.Shapes.count
'Type 1
If sld.Shapes(i).Type = msoAutoShape Then
it = it & "AutoShape" & vbNewLine
right = False
End If
'Type 2
If sld.Shapes(i).Type = msoCallout Then
it = it & "Callout." & vbNewLine
right = False
End If
'Type 3
If sld.Shapes(i).Type = msoChart Then
it = it + "Chart." & vbNewLine
right = False
End If
'Type 4
If sld.Shapes(i).Type = msoComment Then
'it = it + "a Comment. Type : " & .Type
End If
'Type 5
If sld.Shapes(i).Type = msoFreeform Then
it = it + "Freeform." & vbNewLine
right = False
End If
'Type 6
If sld.Shapes(i).Type = msoGroup Then
it = it + "Group." & vbNewLine
' If it's a group them iterate thru
' the items and list them
it = it & vbCrLf & "Comprised of..."
'For Ctr = 1 To .GroupItems.Count
' it = it & vbCrLf & _
' .GroupItems(Ctr).Name & _
' ". Type:" & .GroupItems(Ctr).Type & vbNewLine
'Next Ctr
right = False
End If
'Type 7
If sld.Shapes(i).Type = msoEmbeddedOLEObject Then
it = it + "Embedded OLE Object" & vbNewLine
right = False
End If
'Type 8
If sld.Shapes(i).Type = msoFormControl Then
it = it + "Form Control" & vbNewLine
right = False
End If
'Type 9
If sld.Shapes(i).Type = msoLine Then
'it = it + "a Line. Type : " & .Type
End If
'Type 10
If sld.Shapes(i).Type = msoLinkedOLEObject Then
'it = it + "a Linked OLE Object. Type : " & .Type
'With .LinkFormat
' it = it & vbCrLf & "My Source: " & _
' .SourceFullName
'End With
End If
'Type 11
If sld.Shapes(i).Type = msoLinkedPicture Then
it = it + "Linked Picture" & vbNewLine
'With .LinkFormat
' it = it + it & vbCrLf & "My Source: " & _
' .SourceFullName
'End With
right = False
End If
'Type 12
If sld.Shapes(i).Type = msoOLEControlObject Then
it = it & "OLE Control Object" & vbNewLine
'right = False
End If
'Type 13
If sld.Shapes(i).Type = msoPicture Then
it = it & "Embedded picture" & vbNewLine
right = False
End If
'Type 14
If sld.Shapes(i).Type = msoPlaceholder Then
'it = it & "text placeholder (title or regular text--" & _
' "not a standard textbox) object." & _
' "Type : " & .Type
' right = False
End If
'Type 15
If sld.Shapes(i).Type = msoTextEffect Then
'it = it + "WordArt (Text Effect). Type : " & .Type
End If
'Type 16
If sld.Shapes(i).Type = msoMedia Then
it = it & "Media object .. sound, etc" & vbNewLine
'With .LinkFormat
' it = it & vbCrLf & " My Source: " & _
' .SourceFullName
'End With
right = False
End If
'Type 17
If sld.Shapes(i).Type = msoTextBox Then
'it = "a Text Box."
End If
'Type 18 = msoScriptAnchor, not defined in PPT pre-2000 so we use the numeric value
'Case msoScriptAnchor
If sld.Shapes(i).Type = 18 Then
it = it & "ScriptAnchor" & vbNewLine
right = False
End If
'Type 19 = msoTable, not defined in PPT pre-2000 so we use the numeric value
'Case msoTable
If sld.Shapes(i).Type = 19 Then
'it = " a Table. Type : " & .Type
End If
'Type 19 = msoCanvas, not defined in PPT pre-2000 so we use the numeric value
'Case msoCanvas
If sld.Shapes(i).Type = 20 Then
it = it + "Canvas" & vbNewLine
right = False
End If
'Type 21 = msoDiagram, not defined in PPT pre-2000 so we use the numeric value
'Case msoDiagram
If sld.Shapes(i).Type = 21 Then
it = it + "Diagram" & vbNewLine
right = False
End If
'Type 22 = msoInk, not defined in PPT pre-2000 so we use the numeric value
'Case msoInk
If sld.Shapes(i).Type = 22 Then
it = it + "Ink shape" & vbNewLine
right = False
End If
'Type 23 = msoInkComment, not defined in PPT pre-2000 so we use the numeric value
'Case msoInkComment
If sld.Shapes(i).Type = 23 Then
it = it + "InkComment" & vbNewLine
right = False
End If
'Type -2
If sld.Shapes(i).Type = msoShapeTypeMixed Then
it = "Mixed object (whatever that might be)" & nvNewLine
right = False
End If
Next i
Next