|
みなさまこんにちは。
題名にある通り、Excelの参照設定を行うコードです。
マクロAutoExec から呼び出すと、自動参照されると思います。
Function Excelの参照設定()
Dim Refs As References
Dim xlsGUID As String
Dim Majo As Long
Dim Mino As Long
Dim i As Long
xlsGUID = "{00020813-0000-0000-C000-000000000046}"
Set Refs = Application.References
For i = Refs.Count To 1 Step -1
If Refs(i).IsBroken Then
Debug.Print Refs(i).Guid
Application.References.Remove Refs(i)
Else
If Refs(i).Guid = xlsGUID Then Application.References.Remove Refs(i)
End If
Next
Set Refs = Nothing
Select Case SysCmd(acSysCmdAccessVer)
Case 8: Majo = 1: Mino = 2 'AC97
Case 9: Majo = 1: Mino = 3 'AC2000
Case 10: Majo = 1: Mino = 4 'AC2002
Case 11: Majo = 1: Mino = 5 'AC2003
Case Else: GoTo ErrEXE
End Select
Application.References.AddFromGuid xlsGUID, Majo, Mino
Exit Function
ErrEXE:
MsgBox "エクセルの参照設定を手動で行ってください"
End Function
|
|