Activate Workbook Code Only Works On Some PCs

  • Hi,


    I wrote code to update some workbooks. The code opens the workbooks and then activates the workbook to add the update.


    I was tired when I wrote the code to activate the workbook and it is written:

    Code
    Workbooks("Update").Activate


    The updates have already been sent out and it is not working on some computers. (If I change the code to

    Code
    Workbooks("Update.xls").Activate

    it works fine.)


    Is there some option in the VBA editor that I can have people change on their computer so the code will run? Why does it work on some computers and not others?


    (Unfortunately, rewriting the code to add ".xls" and resending everything isn't an option.)


    Thank you for any insight.
    Andy

  • Re: Activate Workbook


    Just a basic question here:


    Are your users answering "Yes" when prompted to enable macros when the workbook is opened? If their macro security setting is set to "High", then the workbook will open without any prompt but none of the code will function.


    Set the macro security level to "Medium" (prompts the user and allows them to choose whether or not to enable macros.)


    Make sure they answer "Yes" to the prompt.



    AAE

  • Re: Activate Workbook


    Hi Andy


    I hope I'm wrong, but this problem is related to a Windows setting, not an excel's setting.


    In fact, if you open the Windows Explorer and list the Update.xls's folder you see it either like


    Update.xls


    or as


    Update


    This depends on a preference that you set in


    Tools>Folder Options>View


    It's called


    "Hide extensions for known file types"


    My guess is that some of the users have this preference set and others don't.


    If this is the case you'll have to tell them all to check this option (and hope they don't mind).


    HTH
    lecxe

  • Re: Activate Workbook


    That was my Oz lesson for the day, lecxe, thank you :)

    Code
    Workbooks("Update.xls").Activate ' works either way
    Workbooks("Update").Activate ' works only with Hide extensions for known files types


    ... I would :mad: mind if someone asked me to change this setting.

    [SIZE=1]Entia non sunt multiplicanda sine necessitate.[/SIZE]

  • Re: Activate Workbook


    shg, thanks for taking the time to confirm.


    Quote

    ... I would mind if someone asked me to change this setting.



    I would mind too. I always have that option unchecked.


    If I had to use the code and could not edit it, I'd write some automatic solution like using the workbook events to set the option on open, and reset it on close.


    I hope Andy's users don't mind.


    Cheers
    lecxe

  • Re: Activate Workbook Code Only Works On Some PCs


    Quote from Dave

    Use both with

    Code
    On Error Resume Next


    Quote from lecxe

    ... I'd write some automatic solution like using the workbook events to set the option on open, and reset it on close.


    Preseumably, if the OP could do either of those, he could also do the much simpler thing:

    Quote from OP

    (Unfortunately, rewriting the code to add ".xls" and resending everything isn't an option.)

    [SIZE=1]Entia non sunt multiplicanda sine necessitate.[/SIZE]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!