Results 1 to 6 of 6
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    link from wbook.... (2000 sr 1)

    I have a sheet i wbook.
    In the sheet is present button.
    I have assigned to the button a code in sheetcode.
    Now with aother code a copy this sheet and svae it in a new path.
    Now when i open the new wbook saed and click on button the code start but open during code the original wbook where the sheet i have saved...
    Why?

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: link from wbook.... (2000 sr 1)

    Because you assigned a macro to it which is in the original workbook. So when you copy the sheet, the button is copied as well as is the assigned macro reference to the original workbook

    Steve

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: link from wbook.... (2000 sr 1)

    Yes... with a tool i have see is as you tell me.
    How to resolve ? havea new way?

  4. #4
    Lounger
    Join Date
    Feb 2008
    Location
    Chertsey, Surrey, United Kingdom
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: link from wbook.... (2000 sr 1)

    Hello Sal21

    In your copied macro you will probably have a reference to the workbook from where you copied it, for example set wb = workbooks("yourworkbookname"), you need to change it to the new workbook name

    Roger

  5. #5
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: link from wbook.... (2000 sr 1)

    Instead of using a command button from the FORMS toolbar which references a macro in a particular notebook, use a command button from the controls toolbox items which are linked to code in the worksheet.

    If you use the control toolbox /worksheet code combination, copying the sheet will copy both and your code will run from the copied worksheet instead of creating a external link.

    Steve

  6. #6
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: link from wbook.... (2000 sr 1)

    Tks resolved with:...use a command button from the controls toolbox items
    Tks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •