0

I'm trying to set namespace property from Shell.Application object dynamically.

With CreateObject("Shell.Application").Namespace(FolderName)
    ExtendProperty = .GetDetailsOf(.Items.Item(FileName), 143)
End With

When values for FolderName and for FileName are fixed(hard coded) snippet is working. But when I try to pass them in as a variables; error Run-time error 91 - Object variable or With Block variable not set. is returning. Also I need to assign returned value to variable for later use; ExtendProperty. I'm a bit new to VBA and could not find anything on the internet(Scopes, locals, etc.) for this specific case.

0

1 Answer 1

3

To avoid the error mentioned pass variables as variants

Sub TEST2()
    Dim ExtendProperty As Variant
    Dim folderName As Variant, FileName As Variant
    folderName = "C:\Users\User\Desktop\TestFolder"
    FileName = "Test.xlsx"
    With CreateObject("Shell.Application").Namespace(folderName)
       ExtendProperty = .GetDetailsOf(.Items.item(FileName), 143)
    End With
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.