VBA fails when more than one document is open

I developed a complex program for manipulating a multitab workbook and distributing it within the company. I did all the development work with only the one workbook open. When users open the workbook and have other workbooks open, the focus appears to change
among the workbooks. As a result, some of the macros try to run against the other workbooks and not the intended workbook.
Most of the programming uses ActiveWorkbook or ActiveSheet. How do I ensure the macros run against the desired workbook?

Re:  regain control over when code runs
Some Options...
1.  Put a button on the sheet and let the user decide when to run the code
2.  Change ActiveWorkbook to ThisWorkbook
3.  Change ActiveSheet to ThisWorkbook.ActiveSheet
4.  Use the actual workbook and sheet names... Workbooks("Sludge").Worksheets("Mud")
Also suggest you find somebody in the  company to try your code before doing a wide distribution.
Jim Cone
Portland, Oregon USA
free & commercial excel programs (n/a xl2013)
https://jumpshare.com/b/O5FC6LaBQ6U3UPXjOmX2

Similar Messages

  • Finder crashes when more than one window is open

    I've seen others having problems with Finder crashing in OS X Mavericks, and I've had a similar, though slightly different problem. I can work within one window in Finder fine, but any time I open a second window (or a second tab, one of the new features) Finder will crash. I can't copy anything between drives. Here's what I've tried so far to fix it- everything has failed:
    1- Boot in Safe Mode
    2- Kill every other running program (i.e. Dropbox, Droplr, etc.)
    3- Re-install OS X Mavericks from a USB Drive
    4- Repair disk permissions.
    5- Zap PRAM
    Nothing has helped. For your reference, I'm running a late 2009 iMac I7 with 8GB of RAM, and several external USB drives. Any advice would be appreciated.

    You need to look in your user Library/Preferences for the com.apple.finder.plist. Either hold down the option key while using the Finder “Go To Folder” command and select your user Library in your home folder or use the Finder “Go To Folder” command and enter ~/Library/Preferences/com.apple.finder.plist.  Move the .plist to your desktop.
    Re-launch Finder by loggin out/in and test. If it works okay, delete the plist from the desktop.
    If the same, return the .plist to where you got it  from, overwriting the newer ones.
    If you prefer to make your User library permanently visible, use the Terminal command found below.
    Show User Library
    You might want to bookmark the command. I have to use it again after every update. I have also been informed that if you drag the user library to Finder it will remain visible.
    If that doesn't work, the next time the problem happens, note the date and time the problem occurred, then go to Applications/Utilities/Console and copy the log starting at the time of the crash. Paste the log in a reply. Please do not use a screen shot as they can be hard to read. If there are repeated runs of the same messages, please post only one run. Be selective about what you post and don’t  post huge amounts. Make sure there is no personal data visible. Information learned from Linc Davis.

  • TS3899 Hi. How do I attach more than one document to an email on the iPad, especially if they come from different apps? When writing an email on the iPad there's no option for attachments.

    Hi. How do I attach more than one document to an email originating from my iPad, especially if the documents come from different apps? When starting an email there's no option for attachments, unless you send the document from inside an app like iBook and then you can only send one at a time.

    How to add, send and open iPad email attachments
    http://www.iskysoft.com/apple-ipad/ipad-email-attachments.html
     Cheers, Tom

  • PRoblem when posting more than one document

    Hi all,
    I'm using BAPI    BAPI_GOODSMOVEMENT_CREATE to post the documents for PO_GR.when i post one document through text file it is done succesfuully. when i'm posting more than one document it is giving error "posting not possible".
    My code is as follows:
    loop at i_data.
    concatenate '0'   i_data-stor_loc  into i_data-stor_loc.
    concatenate '00'  i_data-plant     into i_data-plant.
        i_item-po_number  = i_data-po_no.
        i_item-po_item    = i_data-po_item.
        i_item-move_type  = i_data-mvt_type.
        i_head-doc_date   = doc_date.
        i_head-pstng_date = post_date.
        i_head-ref_doc_no = i_data-del_note.
        i_item-entry_qnt  = i_data-entry_qty.
        i_item-stge_loc   = i_data-stor_loc.
        i_item-plant      = i_data-plant.
        i_item-stck_type  = i_data-stk_type.
        i_item-batch      = i_data-batch.
    I_ITEM-move_val_type      = i_data-move_batch.
        APPEND: i_item,i_head.
        CLEAR:i_item.
      ENDLOOP.
    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
       EXPORTING
         goodsmvt_header             = i_head
         goodsmvt_code               = i_code
       TESTRUN                     = ' '
      IMPORTING
      GOODSMVT_HEADRET            =
        MATERIALDOCUMENT            = matdoc
       MATDOCUMENTYEAR             =
       tables
         goodsmvt_item               = i_item
       GOODSMVT_SERIALNUMBER       =
         return                      = return
      IF return IS INITIAL.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      ENDIF.
      LOOP AT return.
        WRITE: return-message.
      ENDLOOP.
      WRITE: matdoc.
    PLease specify where i'm going wrong.
    Regards,
    SImha.

    Hi,
    I had used the same FM to post multiple documents, but never faced this error.
    *- Header
      MOVE: sy-datum TO bapigm_head-pstng_date,
            sy-datum TO bapigm_head-doc_date,
            sy-uname TO bapigm_head-pr_uname,
            v_mblnr  TO bapigm_head-ref_doc_no,
            con_bfwms_bestand TO bapigm_head-ext_wms.
    *- Item
    *- Populate item data
      LOOP AT i_items_trans.
        CLEAR ibapigm_item.
    *- Convert the matnr backto 18 char form (External)
        CALL FUNCTION 'CONVERSION_EXIT_MATN2_INPUT'
          EXPORTING
            input            = i_items_trans-matnr
          IMPORTING
            output           = i_items_trans-matnr
          EXCEPTIONS
            number_not_found = 1
            length_error     = 2
            OTHERS           = 3.
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        ibapigm_item-material   = i_items_trans-matnr.
        ibapigm_item-plant      = i_items_trans-werks.
        ibapigm_item-stge_loc   = i_items_trans-lgort.
        ibapigm_item-move_type  = '101'.   "Goods Receipt
        ibapigm_item-mvt_ind    = 'B'.     "Goods Movement for PO
        ibapigm_item-po_number  = i_items_trans-ebeln.
        ibapigm_item-po_item    = i_items_trans-ebelp.
        ibapigm_item-entry_qnt  = i_items_trans-ktmng.
        ibapigm_item-entry_uom  = i_items_trans-meins.
        APPEND ibapigm_item.
      ENDLOOP.
    *-Call FM
      CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
        EXPORTING
          goodsmvt_header  = bapigm_head
          goodsmvt_code    = bapigm_code
        IMPORTING
          goodsmvt_headret = bapigm_headret
        TABLES
          goodsmvt_item    = ibapigm_item
          return           = ibapigm_ret.
    *- Commit on Success
      IF NOT bapigm_headret-mat_doc IS INITIAL.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    Regards,
    Raj

  • How can I send more than one document on an email

    how can I send more than one document on one email

    Thank you but I understand that form of attaching a document. However when I select a document then click 'Share' I have the option of sending the document by email as a word or pages document or pdf, what I want to know is can I use this procedure to send more than one document per email and if I can how?

  • Adding More than one document to a cell in a dataform

    Hi All,
    I am using EPM 11.1.1.1.0 .
    I have a planing application and I need to add three documents to a cell in a data form.
    Is there a way i can do this...
    I can add one document and can open it as well but did not find a way of adding more than one document. Is it supported on Hyperion Planning ?
    Also if we have a document attached to a cell text ...Is there a way to print it out from Hyperion Planning or Workspace?
    Regards.
    Alicia
    Edited by: Alicia on Aug 6, 2009 6:39 AM

    Hi,
    I believe it will be just one document, I say that because when you go to the cell and choose open document then it is aimed at opening just one document.
    As for printing from cell text, you would have to open the document first before being able to print.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • More than one document in a Batch Input Session?

    Hi to all,
    I need to post more than one document with a Batch Input of MB1A transaction.
    The user asked me to create only one session no mater how meny documents I've to post.
    The problem is that when I run the record (SM35), when the first document is saved, the batch input finishes and the rest of de documents in the record can't be processed.
    Does anyone knows if this is possible? or I've to create a new session for each document to de treated?
    Thanks to all.
    Nico.-

    You should be able to post all documents in one session.
    When you go in SM35 session, can you see multiple transactions in that session?
    All transaction postings  should happen within function 'BDC_OPEN_GROUP' and 'BDC_CLOSE_GROUP' in your program.
    Cheers,
    Vikram

  • Illustrator CS6 freezing with more than one document

    I have always had multiple files open at a time when using illustrator but all day today the program has been freezing everytime i open more than one document. I am able to use the program now if i only have one file open but it freezes as soon as i open the second file. I have restarted my computer twice and i have closed every other program on my computer and none of that helped. I have a macbook pro and i save all of my illustrator files on an external hard drive. As any one else experienced this?
    Thanks for the help

    Have you added any Illustrator plug ins or software recently, or enabled new fonts? Try working with some other doumcnets if you have not, to help narrow down if this is a global problem affecting all documents.
    Create a new user account and log in as that
    Run applications /utilities/disk utility and fix permissions
    Is there a common image used in these doucments, may be corrupt and sometimes opening and resaving a .psd for example

  • Multiple select queries used in Excel BI report ,fetching data from Sharepoint DB(SP2010_Prod_ProjectServer) causing blockage on DB ,when more than one workbook(same copy of Excel BI Report) refreshed using Refresh All option.

    I am using mutiple select queries to fetch data from Project Server 2010 DB(its sharepoint DB) and these queries fetch data in Excel BI report by establishing connection with DB using instance name and all. I have enhance all these select queries and data
    is being fetched in secs. but when more than one copy of same Excel BI report is refreshed using 'Refresh All' option, then these select queries cause blockage on DB.
    Please let me know mitigation for this blockage issue.
    Should I use begin transaction and commit transaction statements/ shared lock statements.
    please reply

    Hi,
    run same query at the same time?

  • How to display more than one documents on windows 8 desktop?

    how to display more than one documents on windows 8 desktop?

    Adobe Reader Touch doesn't show more than one file on screen and doesn't show them on the desktop. Apparently these are very old fashioned things that Microsoft doesn't think we'll want to do any more and calls them "legacy" to make them sound antiquated.
    If you want to do these things use the legacy Adobe Reader, a much more powerful and flexible app (and not obsolete in the slightest). http://get.adobe.com/reader . There are no legacy apps in the Windows App Store.

  • Can we upload more than one document at a time ?

    It will take me forever to upload all my documents into the acrobat cloud , ONE at a time....is there a quicker way to do it? If not,  will there be soon? Because that would really help me and possibly others to get it done faster...

    Hi melanie1621
    Yes You can upload more than one document ...
    Please do the following :
    1. Click on upload files button under Acrobat.com
    2. A pop will open .
    3. Select more than one file by keeping the CTRL button pressed.
    4. Once, you select all the files , Click on Open ...
    It Will Start uploading all your files ...!

  • Taking print of more than one document at a time???

    Hi sap experts,
    Presently my client is taking print of one document at a time. Is there any process/system through which he can take print of more than one document at a time in a specified format by putting the document number range.  
    Regards,
    Sumeya offrin

    Hi melanie1621
    Yes You can upload more than one document ...
    Please do the following :
    1. Click on upload files button under Acrobat.com
    2. A pop will open .
    3. Select more than one file by keeping the CTRL button pressed.
    4. Once, you select all the files , Click on Open ...
    It Will Start uploading all your files ...!

  • Remove extended features more than one document at a time.

    Does anybody know how to remove the extended features in Adobe files in batch mode? Since the newest upgrade of Adobe reader, we are having to remove the extended features and have 702 forms to do this with! Our users are trying to add their image signature and now it prompts them to do a save as and then locate the saved copy. Seems there must be an easier way or a fix for this?  Thanks all.

    Hi melanie1621
    Yes You can upload more than one document ...
    Please do the following :
    1. Click on upload files button under Acrobat.com
    2. A pop will open .
    3. Select more than one file by keeping the CTRL button pressed.
    4. Once, you select all the files , Click on Open ...
    It Will Start uploading all your files ...!

  • C7280 - printing more than one document at a time

    Does anyone know a quicker way of scanning in (using the feeder) several different documents at a time, as opposed to different pages of the same document.  At the moment, I seem to have to exit too far out of the software at the end of each doc'.
    This is what I'm doing:
    a) select SCAN DOCUMENT
    b) select file format ie PDF
    c) If document loaded on feeder, printer takes however many pages in the tray and scans into one document.
    d) On pressing Finish, question comes up asking whether you'd like to add another page to the document.  If you press Yes - it simply adds it the exisiting document being scanned and if you press No, it saves the existing document but exits right out  taking you right back to the home page which then remains greyed out for a while until, the previous document has been saved. 
    Very appreciative of a time saving irritation lessening answer!! :-)

    Hi melanie1621
    Yes You can upload more than one document ...
    Please do the following :
    1. Click on upload files button under Acrobat.com
    2. A pop will open .
    3. Select more than one file by keeping the CTRL button pressed.
    4. Once, you select all the files , Click on Open ...
    It Will Start uploading all your files ...!

  • My hard drive has 70.93 GB available, yet when i have more than one internet tab open, i have to force quit google chrome because 'there is no more available application memory'. How can I solve this? I have a 2009 macbook pro running on 10.6.8.

    My hard drive has 70.93 GB available, yet when i have more than one internet tab open, i have to force quit google chrome because 'there is no more available application memory'. How can I solve this? I have a 2009 macbook pro running on 10.6.8. I have tried updating to mavericks through the mac app store but after it downloading for a day i got an error message saying there was a problem with the download. The same thing happens if i try to update itunes or the mac app store. After research, i have also tried repairing disk permissions, but every time they do get repaired the 'repair' button still appears, i'm not sure if it's because it was unable to repair the initial problems or if it just keeps detecting new ones.

    2 GBs is a minimum in which you can do many things, but not concurrently. Be very careful to not install third-party add-ons, limit the number of applications you choose to enter in Login Items, run as few applications concurrently as you demand.
    I would consider adding more RAM to your computer. Your model supports 8 GBs, so I would install that.

Maybe you are looking for