Hey all,

I've got a strange issue, currently our corporate systems run on Win 2000, and Office 2000. Our Tech people are in the processes on upgrading us to XP and Office 2003. Within our department we have a customised normal.dot template that everyone has a copy of. We had to customise the Open and Save option in Word as far too many deletion was happening. This works perfectly in Word 2000, but in 2003 the customised Open option just hangs.

The below code refers to the customised open, I've tried to catch out the error by remming out the error handling 'end nows' but there doesn't seem to be an error.

The only differences I've found is in the References from 2000 to 2003

Office 2000 Refs
VB for Apps
MS Word 9.0 OL
OLE Automation
MS Forms 2.0 OL
MS Office 9.0 OL
MS Oulook 9.0 OL
MS Shell Controls and Auto

Office 2003 Refs
VB for Apps
MS Word 11.0 OL
OLE Automation
MS Forms 2.0
MS Office 11.0 OL
MS Outlook 11.0 OL
MS Shell Controls and auto

Is the ref version difference causeing the issue?

Code:
Dim UserCancelled As Boolean, InvalidSelection As Boolean
Dim strUsersFolder As String, strLastFolder As String
Dim mySelectedFile As String 'folder/file selected by user in ShowFolderList
Dim MyFolder As Integer 'used to store user's default folder based on their Word username
Dim strDocType As String

Const myWork As String = "K:\"
Const myHome As String = "H:\"

Private Sub CommandButton1_Click()
    MsgBox "If your folder can't be found, ensure that your user name is set up in Word." & Chr(13) & Chr(13) & "Tools/Options/User Information/User Name should be your name (Firstname Surname).", vbOKOnly
End Sub

Private Sub labChooseFolderH_Click()
    ChooseFolderH
End Sub

Private Sub labChooseFolderK_Click()
    ChooseFolderK
End Sub

Private Sub labChooseFolderLast_Click()
    ChooseFolderLast
End Sub

Private Sub labChooseFolderMy_Click()
    ChooseFolderMy
End Sub

Private Sub UserForm_Initialize()
On Error GoTo ENDNOW
    'Get last selected folder 'set by ShowFolderList
    strLastFolder = Options.DefaultFilePath(path:=wdDocumentsPath)
    'Get username
    strUsersFolder = Word.Application.UserName
    'Update username to match folder name for user and use as default folder
    Dim myLen, FName, SName
    myLen = InStr(1, strUsersFolder, " ")
    FName = Mid(strUsersFolder, 1, myLen)
    SName = Mid(strUsersFolder, myLen)
    strUsersFolder = myWork & LTrim(SName) & ", " & FName 'used by ShowFolderList routine
    
Exit Sub
ENDNOW:
End Sub

Private Sub btnCancel_Click()
     Unload Me
End Sub

Sub ShowFolderList()
On Error GoTo ENDNOW
'Set a reference to the "Microsoft Shell Controls And Automation" library

Dim SH As Shell32.Shell
Dim Fldr As Shell32.Folder2
Set SH = New Shell32.Shell
Dim myTitle As String, myRoot As String, chkFileType

myTitle = "Double click to open each folder and choose OK to open Word Document"

    If MyFolder = 1 Then 'user's main folder
        myRoot = strUsersFolder
    ElseIf MyFolder = 2 Then 'user's last selected folder
        myRoot = strLastFolder
    ElseIf MyFolder = 3 Then 'K drive
        myRoot = myWork
    ElseIf MyFolder = 4 Then 'H drive
        myRoot = myHome
    End If
        
    'Runtime Error 5 will occur in Win 2000 if txt or rtf are opened on the root. Trapped below
    On Error Resume Next
    Set Fldr = SH.BrowseForFolder(0, myTitle, 16384, myRoot)
    If Err.Number <> 0 Then
        If Err.Number = 5 Then 'txt or rtf was selected on the root
            MsgBox "Not possible to open this file type in the root folder"
            UserCancelled = False
            InvalidSelection = True
            Me.Enabled = True
            GoTo ReleaseObjs
        End If
    End If
    
    'No Runtime Error
    If Fldr Is Nothing Then
        'User chose Cancel
        UserCancelled = True
    Else
        UserCancelled = False
        If Fldr.Self.IsFolder = True Then 'User has not selected a file
            InvalidSelection = True
            MsgBox "You have not chosen a document"
            Me.Enabled = True
            GoTo ReleaseObjs


        Else 'User has selected a file
            mySelectedFile = Fldr.Self.path
            'Validate File Type
            chkFileType = InStr(1, mySelectedFile, ".doc") '.doc
            If chkFileType = 0 Then
                chkFileType = InStr(1, mySelectedFile, ".DOC") '.DOC 'post save/open version 1 files 08/10/08
                If chkFileType = 0 Then
                    chkFileType = InStr(1, mySelectedFile, ".txt") '.txt
                    If chkFileType = 0 Then
                        chkFileType = InStr(1, mySelectedFile, ".rtf") '.rtf
                        If chkFileType = 0 Then
                            '<> .doc, .txt, .rtf
                            InvalidSelection = True
                            MsgBox "Can not open file"
                            Me.Enabled = True
                            GoTo ReleaseObjs
                        Else
                            InvalidSelection = False '.rtf ok
                        End If
                    Else
                        InvalidSelection = False '.txt ok
                    End If
                Else
                    InvalidSelection = False '.doc ok
                End If
            Else
                InvalidSelection = False '.DOC ok
            End If
        End If
        
        'Set filepath as last selected location
        Dim myLen, myChar
        myLen = 1
        While myLen > 0
            myChar = myLen
            myLen = InStr(myLen + 1, mySelectedFile, "\")
        Wend
        strLastFolder = Mid(mySelectedFile, 1, myChar)
        Options.DefaultFilePath(path:=wdDocumentsPath) = strLastFolder

    End If

ReleaseObjs:
Set SH = Nothing
Set Fldr = Nothing

Exit Sub
ENDNOW:
'Error trap some file types, e.g. bas etc.
MsgBox "Can not open file", vbExclamation, "DLS"
InvalidSelection = True
Me.Enabled = True
Word.Application.Activate
End Sub

Private Sub Userform_QueryClose(Cancel As Integer, closemode As Integer)
    If closemode = vbFormControlMenu Then
        Cancel = True
    End If
End Sub

Public Function FileFolderExists(strFullPath As String) As Boolean
    'Check if a file or folder exists
    If Not Dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = True
End Function

Private Sub ChooseFolderMy()
On Error GoTo ENDNOW
    If FileFolderExists(strUsersFolder) Then
        MyFolder = 1
        Me.Enabled = False
        ShowFolderList
        If UserCancelled = True Or InvalidSelection = True Then 'User cancelled BrowseForFOlder or did not select a file
            Me.Enabled = True
            Word.Application.Activate
            Exit Sub
        End If
        OpenMyFile
    Else
        MsgBox "Folder does not exist!  Ensure that your user name is set up in Word." & Chr(13) & Chr(13) & "Tools/Options/User Information/User Name should be your name (Firstname Surname)"
    End If
Exit Sub
ENDNOW:
End Sub

Private Sub ChooseFolderLast()
On Error GoTo ENDNOW
    If FileFolderExists(strLastFolder) Then
        MyFolder = 2
        Me.Enabled = False
        ShowFolderList
        If UserCancelled = True Or InvalidSelection = True Then 'User cancelled BrowseForFOlder or did not select a file
            Me.Enabled = True
            Word.Application.Activate
            Exit Sub
        End If
        OpenMyFile
    Else
        MsgBox "Folder can not be located!"
    End If

Exit Sub
ENDNOW:
End Sub

Private Sub ChooseFolderK()
On Error GoTo ENDNOW
    If FileFolderExists(myWork) Then
        MyFolder = 3
        Me.Enabled = False
        ShowFolderList
        If UserCancelled = True Or InvalidSelection = True Then 'User cancelled BrowseForFOlder or did not select a file
            Me.Enabled = True
            Word.Application.Activate
            Exit Sub
        End If
        OpenMyFile
    Else
        MsgBox "Drive can not be located!"
    End If
Exit Sub
ENDNOW:
End Sub

Private Sub ChooseFolderH()
On Error GoTo ENDNOW
    If FileFolderExists(myHome) Then
        MyFolder = 4
        Me.Enabled = False
        ShowFolderList
        If UserCancelled = True Or InvalidSelection = True Then 'User cancelled BrowseForFOlder or did not select a file
            Me.Enabled = True
            Word.Application.Activate
            Exit Sub
        End If
        OpenMyFile
     Else
        MsgBox "Drive can not be located!"
    End If
Exit Sub
ENDNOW:
End Sub

Private Sub OpenMyFile()
On Error GoTo ENDNOW
    
    Documents.Open mySelectedFile
    Unload Me
    'Set Word focus
    Word.Application.Activate
    End

Exit Sub
ENDNOW:
End 'kill if any other non trapped errors occur opening file
End Sub