这是完整的代码..
Private Declare Function RegOpenKey Lib "advapi32.dll" _
Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, _
phkResult As Long) As Long
Declare Function RegQueryValue Lib "advapi32.dll" _
Alias "RegQueryValueA" (ByVal Hkey As Long, ByVal lpSubKey As String, _
ByVal lpValue As String, lpcbValue As Long) As Long
Private Declare Function RegCloseKey _
Lib "advapi32.dll" (ByVal Hkey As Long) As Long
Public Sub AccessAnObject()
' Holds an indeterminate object.
Dim AObj As InlineShape
' Holds the BMP file class.
Dim BMPClass As String
' Holds picture statistical data.
Dim Output As String
' Holds the Registry key reference.
Dim RegKeyRef As Long
' Holds the length of the Registry data.
Dim RegLength As Long
' Get the BMP file class.
' Open the Registry key.
RegOpenKey ROOT_KEYS.HKEY_CLASSES_ROOT, ".bmp", RegKeyRef
' Determine whether the key exists.
If RegKeyRef = 0 Then
' Display an error.
MsgBox "Couldn't open BMP file Registry setting.", _
vbOKOnly Or vbExclamation, _
"Registry Error"
' Exit the sub.
Exit Sub
End If
' Determine whether the required information exists. If
' so, get the data length.
RegQueryValue RegKeyRef, "", BMPClass, RegLength
' Fill the string with the required spaces.
BMPClass = VBA.String(RegLength, " ") ' Retrieve the value.
RegQueryValue RegKeyRef, "", BMPClass, RegLength
BMPClass = Left(BMPClass, Len(BMPClass) - 1)
' Close the Registry.
RegCloseKey (RegKeyRef)
' Check each inline shape.
For Each AObj In ThisDocument.InlineShapes
' Select the object and show that it is selected.
AObj.Select
MsgBox "Object Number " + _
CStr(AObj.Field.Index) + " is Selected", _
vbInformation Or vbOKOnly, "Object Select"
' If this is a sound object, play it.
If AObj.OLEFormat.ClassType = "SoundRec" Then
AObj.OLEFormat.DoVerb wdOLEVerbPrimary
End If
' If this is a picture object, display some
' statistics.
If AObj.OLEFormat.ClassType = BMPClass Then
' Get the height and width and then display it.
Output = "Height: " + CStr(AObj.Height) + _
vbCrLf + _
CStr(Application.PointsToInches(AObj.Height)) _
+ " Inches" + vbCrLf + _
"Width: " + CStr(AObj.Width) + vbCrLf + _
CStr(Application.PointsToInches(AObj.Width)) _
+ " Inches"
MsgBox Output, vbInformation Or vbOKOnly, _
"Picture Statistics"
End If
Next
End Sub
希望你能在你自己的笔记本电脑上运行这个,看看问题是什么..其他人帮助我声明函数和sub但是这次它的运行时错误424存在.. :(
对于那些可以帮助我的人,非常感谢你!