Hi,
I prepared a template for another person and everything worked fine on my end, but on their end they were not getting a prefix text as required.
I isolated the problem to a Select Case statement, but I can't for the life of me figure out what the issue could be. As sample of the code is provided below. First a document variable is set to either "Test 1" or "Test 2" and then depending on that variable, two prefix strings are defined.
For some reason on the other person's computer, the Select Case statement isn't working correctly. The expected value of the variable is present and returned, but on their system it just blows right passed the Case "Test 1" statements yet works like a champ using If ElseIf End If:-(
Anyone seen anything like this before or have an explanation? Thanks.
Sub CaseStatementOddity() Dim strPrefix1 As String Dim strPrefix2 As String Debug.Print ActiveDocument.Variables("varTest").Value 'Returned "Test 1" Select Case ActiveDocument.Variables("varTest").Value Case "Test 1" strPrefix1 = "A - " strPrefix2 = "B - " Case "Test 2" strPrefix1 = "C - " strPrefix2 = "D - " End Select Debug.Print strPrefix & " " & strPrefix2 'Returns "A - B -" on my system. Returns "" on other system. End Sub Sub WordAround() Dim strPrefix1 As String Dim strPrefix2 As String If ActiveDocument.Variables("varTest").Value = "Test 1" Then strPrefix1 = "A - " strPrefix2 = "B - " ElseIf ActiveDocument.Variables("varTest").Value = "Test 2" Then strPrefix1 = "C - " strPrefix2 = "D - " End If Debug.Print strPrefix & " " & strPrefix2 'Returns "A - B -" on both systems. End Sub