Question

So I'm in need of creating a short sub in outlook 2010 for people using custom forms to open a specific folder on the network to browse pictures further (which everyone on network has permissions). However I'm a bit confused as this should be a simple script to run, but from the sub running out of Outlook forms, I get a shell error, or wscript errors. Currently I'm getting the error of "Object does not support this property or method: 'objShell.Shell'

So here's my code so far and every wscript or function I've tried seems to give a similar error:

Dim objShell
Dim ShortName
Dim AddressOnly

set objShell = CreateObject("shell.application")
If ClientCode = "1" Then
    objShell.Shell.Open("Server:\path\"& ShortName &" - "& AddressOnly &"\")
        ElseIf ClientCode = "2" Then
        objShell.Shell.Open("Server:\path\"& ShortName &" - "& AddressOnly &"\")
            ElseIf ClientCode = "3" Then
            objShell.Shell.Open("Server:\path\"& ShortName &" - "& AddressOnly &"\")
End if

    set objShell = nothing
Was it helpful?

Solution

So here is the code I've found to be working now for this option to open a folder and display the full contents through explorer.exe:

If ClientCode = "1" Then
    folder = "Server:\path\"& ShortName &" - "& AddressOnly & "\"                                       
    ElseIf ClientCode = "2" Then
    folder = "Server:\path\"& ShortName &" - "& AddressOnly & "\"                                   
        ElseIf ClientCode = "3" Then
        folder = "Server:\path\"& ShortName &" - "& AddressOnly & "\"                               
End if

Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FolderExists(folder) Then
        MsgBox "No Files Exist. You must create the file first before trying to find it.", vbExclamation, "No File Found."
        Exit Sub
    Else
        'moving on
    End If

set WSshell = createobject("wscript.shell")
WSshell.run "C:\WINDOWS\explorer.exe "& folder &"", 1
Set WSshell = nothing
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top