0

I have several macros which run on most of my colleague's computers, but not on one.

When I attempted to run the macro on this colleague's Citrix account, the code failed on the "Workbooks.("Document Name").Activate" line.

I noticed that the document name at the top of the ribbon read, "(document name).xlsm". The "Xlsm" does not appear when the document is opened on my Citrix account.

I think that the "xlsm" is confusing the macro, and that the reason this is appearing is something to do with the version of Excel which is being used on that person's Citrix account.

Does anyone know the solution to this?

0

2 Answers 2

1

Just use Workbooks("Document Name.xlsm").Activate as that will work on all machines, regardless of whether Explorer is set to display file extensions. Also, it is rarely necessary to activate or select anything.

Sign up to request clarification or add additional context in comments.

Comments

0

Instead of relying on the name directly, you can set the workbook name to a variable using 'Like', so you won't need to pull the exact name. Something like this should work:

Dim Book as Workbook
Dim wbk As Workbook

For Each Book In Workbooks
    If Book.Name Like "Document Name*" Then 'Like document name * for wildcard
        Workbooks(Book.Name).Activate
        Set wbk = ActiveWorkbook
    End If
Next Book

This will loop through the open books, find a workbook with a name similar to your choosing, and then activate it. Obviously it needs to be modified to fit your exact needs.

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.