1
Shell.Applicationオブジェクトの名前空間メソッドが、呼び出し側のサブ変数に変数宣言がない場合に失敗するような状況が発生しました。VBA:Shell.Application名前空間関数は、呼び出しサブの変数宣言に依存しません。
単純化されたテストケースは以下の通りです:
によって呼び出されFunction TestShellApplicationNamespace(folder)
Dim oShell: Set oShell = CreateObject("Shell.Application")
Dim oDir: Set oDir = oShell.Namespace(folder)
Debug.Print TypeName(folder)
If oDir Is Nothing Then
Debug.Print "oDir is Nothing"
Else
Debug.Print "oDir is not Nothing"
End If
End Function
:私はこれを実行しているから得る結果は
Sub CallTestShellApplicationNamespace()
Dim folder As String
folder = "C:\"
TestShellApplicationNamespace folder
folder2 = "C:\"
TestShellApplicationNamespace folder2
End Sub
:
String
oDir is Nothing
String
oDir is not Nothing
私はわかりませんよこれがVBA通訳のバグかどうか、私が間違っているかどうか。
EDIT:これを提出した後、また、関連性のある次のように見つかったシェルインタフェース奇数判定
Excel VBA Shell.Namespace returns Nothing