I have a macro that looks at a user's desktop shortcuts to insure that they are formatted properly for my workbooks. The macro works fine on my three PCs. My PCs are all various versions of 64 bit Win 10. My office programs are all 32 bit. Two have Office 14 and 11, one has 365. A client has 64 bit Office 365 and that's where the problem is. My code (attached in a striped down version) uses Shell32 and "WScript.Shell". Reference to Microsoft Shell Controls and Automation is turned on. Can you suggest code that will allow this to work in both 32 bit and 64 bit office? Thank you
VBA Code:
Sub Shortcut()
Dim B As String
Dim FileLoc(3, 2) As String
Dim i As Integer
Dim oShell As Shell32.Shell
Dim oFolder As Shell32.Folder
Dim oWsh As Object
Dim Rw As Integer
Cells.ClearContents
Set oShell = New Shell32.Shell
Set oWsh = CreateObject("WScript.Shell")
FileLoc(1, 0) = Environ("USERPROFILE") & "\DESKTOP"
Set oFolder = oShell.Namespace(FileLoc(1, 0))
For i = oFolder.Items.Count - 1 To 0 Step -1
B = UCase(oFolder.Items.Item(i))
Cells(Rw + 1, 1) = B
Rw = Rw + 1
Next i
End Sub