Excel 2013 VBA 7.1 Workbook Activate Problems

I have 2 workbooks open and during the course of a macro am switching between them. The macro has developed a problem where it seems to disregard the workbook.activate command when running. If I set a breakpoint at the line with the activate command
and step through it, it works fine.
I have tried activating using ThisWorkbook,Worksheets().activate, Workbook(xx).activate, Windows(xx).activate. I have also tried minimizing the other window which I do not want activated, but this causes the main macro to freeze.
This is only a problem at one point in my macro and it works properly elsewhere.

I have 2 workbooks open and during the course of a macro am switching between them. The macro has developed a problem where it seems to disregard the workbook.activate command when running. If I set a breakpoint at the line with the activate command
and step through it, it works fine.
I have tried activating using ThisWorkbook,Worksheets().activate, Workbook(xx).activate, Windows(xx).activate. I have also tried minimizing the other window which I do not want activated, but this causes the main macro to freeze.
This is only a problem at one point in my macro and it works properly elsewhere.
There is no need to "switch" between the workbooks, just assign a reference to them, and access the methods and properties for each workbook.
Dim wb1 as Workbook, wb2 as Workbook
'assuming both workbooks are already open
Set wb1 = Workbooks("Name of First WB")
Set wb2 = Workbooks("Name of Second WB")
Also unless you really need to observe what the macro is doing during execution, there is no reason to have multiple Workbook.Activate statement. Just have one final one at the end of the macro to activate the workbook you really want to see at the end of the
macro execution.

Similar Messages

  • Excel 2013 VBA Compatible with Excel 2010

    Hello,
    I am new at working with VBA and have a question regarding an excel sheet with a VBA macro inserted.
    The sheet was created in Excel 2013 by another user, and my laptop runs Excel 2010.  I get script errors when I run it, however on Excel 2013 it works fine.
    My question is: Is there a way to make Excel 2010 work with Excel 2013 VBA scripts? Perhaps importing the library from Excel 2013 VBA to E-2010?  Or perhaps a way to save a VBA script in E-2013 to be backwards compatible with E-2010?
    Thank you all for your support.

    Open the workbook.
    Select Tools > References...
    The references that are in use have their check box ticked. They are all at the top of the list. Do any of those start with MISSING?
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Activate A Second Worksheet In Excel 2013 VBA

    I have an Excel 2013 workbook with 2 worksheets:
    1) Summary   MNA.Sheets("Summary")
    2) Agreement 1  MNA.Sheets("Agreement 1")
    I've tried all sorts of code to get from 1 to 2 in VBA, but keep getting an error.
    What is the proper code?
    Thanks.
    A. Wolf

    Have you tried
    Worksheets("Agreement 1").Select
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Excel 2013 VBA formatting Listbox 2 columns

    Have 2 listbox - Listbox 1 has 9 columns and is populated by Excel Worksheet Range. Listbox 1 shows formats correctly.
    User selects multiple items from Listbox1 and click a command button to inserts into Listbox2. In Listbox2 the 5th column should show data as h:mm but does not it looks like text. Also, in Listbox2 column 9 should be formatted as date mm/dd/yy and it
    is not.
    How do I write the code to format these columns?
    Code for the Command button is below:
    Private Sub CmdInsert_Click()
        Dim IndexRow As Long
        Dim IndexCol As Long
         With ListBox1
             For IndexRow = 0 To .ListCount - 1
                 If .Selected(IndexRow) Then
                     ListBox2.AddItem .List(IndexRow, 0)
                     For IndexCol = 1 To .ColumnCount - 1
                         ListBox2.List(ListBox2.ListCount - 1, IndexCol) = .List(IndexRow, IndexCol)
                         Next
                  End If
             Next
         End With
    Me.ListBox1.MultiSelect = fmMultiSelectSingle
     Me.ListBox1.ListIndex = -1
     Me.ListBox1.MultiSelect = fmMultiSelectMulti

    A listbox displays the text of the cells in its rowsource. But rowsource can only be a block of cells, so your code needs to read the text from the source cells of listbox1.
        With ListBox1
            For IndexRow = 0 To .ListCount - 1
                If .Selected(IndexRow) Then
                    ListBox2.AddItem .List(IndexRow, 0)
                    For IndexCol = 1 To .ColumnCount - 1
                        ListBox2.List(ListBox2.ListCount - 1, IndexCol) = _
                        Range(ListBox1.RowSource).Cells(IndexRow + 1, IndexCol + 1).Text
                    Next
                End If
            Next
        End With

  • Excel 2003 to 2013 VBA migration bug

    Hello!
    I need to convert mission critical workbooks with much VBA code from Excel 2003 to Excel 2013, of which some were originally created using Excel 97.
    When running any VBA macro I get 0x80028018 errors. A similar problem is described in KB320369 - BUG: "Old format or invalid type library"
    error when automating Excel - however in my case it's
    VBA, not .NET or VSTO and
    I have installed the proper language packs.
    I need to describe more detailed:
    Even when I open the legacy workbook in 2013, create a new blank sheet, delete all old sheets and all VBA code, forms etc., put a new command button in, calling any new VBA sub, I get that error.
    When I create a new workbook from scratch, put a new command button in, calling any new VBA sub, there is no error!
    It also makes no difference, if I save it in compatibility mode xls or as new xlsm. See the screenshots.
    I believe there is some legacy metadata in vbaProject.bin, which makes Excel 2013 choke.
    Thanks!
    L.
    Run-Time Error Message:
    Comparison of the zipped contents of "Book2", the newly created workbook, and "L_VK_1_min", the converted legacy workbook:

    Hi asklucas,
    Are you installing mutiple version of Excel on the same computer? Can you check the wether the reference is correct in tools-reference?
    >>I believe there is some legacy metadata in vbaProject.bin, which makes Excel 2013 choke.<<
    Is it helpful that conver the XLSM to XLSX, then copy the code in to XLSX and save it to XLSM back?
    If not, I suggest that you create a new workbook and copy the orgial code into the new workbook as a workaround.
    Event if there are many workbook, we can write an application to automate this process. Here are some helpful links for your reference:
    Objects (Visual Basic Add-In Model)
    OfficeTalk: Display a List of All VBA Procedures in a Workbook from the Ribbon
    Hope it is helpful.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Excel 2013: Lost VBA Code From Excel 2010

    Just upgraded from Office 2010 to Office 2013.
    Tried to open several of my Excel spreadsheets created in 2010 with Excel 2013. I have spreadsheets that have VBA to perform several functions and routines.
    None of the .xlsm spreadsheets from 2010 work in 2013. I get the following messages:
    "The Visual Basic for Applications (VBA) macros in this workbook are corrupted and have been deleted. The macro corruption most likely exists in the current file. To recover the macros, open a backup copy of this file if you have one."
    OR ...
    "We found a problem with some content in '*******.xlsm'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes."
    Clicking Yes does not help. It removes or tries to fix the issue. Under the developer tab, the "Visual Basic" and "Macros" button is disabled.
    I tried 3 of my different workbooks. They all get the same error. I went back to an Office 2010 installation and all the workbooks open file - without error, and the code executes.
    Advice?

    I'm getting the same problem, but with Excel 2010.
    I've created a workbook with macros in Excel 2010 and couldn't run it in two computers with office 2010. The same problem as above occurs:
    "The Visual Basic for Applications (VBA) macros in this workbook are corrupted and have been deleted. The macro corruption
    most likely exists in the current file. To recover the macros, open a backup copy of this file if you have one."
    This problem happened with other 2 workbooks with macro. It's curious too that another workbook with macro created by
    me is working on these two computers without errors. And, of course, all of the workbooks mentioned works well in the other computers. This problem started when I downgrade the office os this two computers from 2013 to 2010.
    None of the solutions proposed above has worked.
    Any ideas?
    Thanks in advance!

  • Is it possible to still hide Workbooks from the Windows Taskbar in Excel 2013

    Because of the introduction of the SDI in Excel 2013 it is no longer possible to select the option to NOT display workbooks in the Taskbar.
    This causes a major problem with Excel Applications written in VB or VBA which have multiple workbooks open for various reasons but only wanting the user to have access to one workbook at a time.
    Is it possible to still hide these workbooks from the taskbar?
    I did request in beta to still have the Application.ShowWindowsInTaskbar still available via VBA, switching to FALSE  for the life of the Excel instant...but that would have been too easy...
    Thanks in advance for any help
    Steve
    Steve Stretch

    Thanks Jaynet,
    Yes, this is what I also worked out. However hiding the workbook via the .visible = FALSE means you can then no longer reference cells or worksheets via the ActiveCell or ActiveWorkbook objects, which meant a massive re-write to my application. For the benefit
    of other developers I then needed to reference my 'Active' Objects via the Set myActiveWorksheet = anActiveWorkSheet.
    BTW I have given up suggesting things to Microsoft during any beta releases as they have never taken up any suggestions I have ever made in 13 years of receiving Beta's. My software is the biggest Excel Automation program in the world (I suspect) with over
    20 meg of VBA Code. Don't tell me that implementing a simple request of allowing  Application.ShowWindowsInTaskbar
    was beyond Microsoft's ability. Application.EnableEvents lasts for the duration of the Excel instant, this could have behaved in exactly the same way.
    Unfortunately Microsoft's agenda is to no longer satisfy the customer but the shareholders...I could go on....
    Thanks
    Steve
    Steve Stretch

  • Update to Excel 2013 causing a problem with Sage 500 ERP import feature

    I work in an accounting office that relies heavily on importing data from Excel into Sage 500 ERP accounting software.  We recently began updating from Office 2007 to Office 2013.  Now we are running into a
    huge hurdle as we find Excel 2013 no longer supports MDI, and has moved exclusively to SDI.  This is a problem for us, and here's why.
    Sage 500 has a "Data Porter" command which launches Excel, but opens a blank workbook in Excel.  After triggering the Data Porter, we open a previously saved Excel workbook containing our data, select the "Add-Ins"
    tab, and click the appropriate button to begin the import.  In Excel 2007 this works because the workbook with the data opens in the same "window" as the blank workbook.
    In Excel 2013, the workbook containing the data can only be opened in it's own new window which has not established the line of communication with Sage 500's Data Porter, and the import function is not available.
    So far the only workaround we have found is to right-click on a tab in the file containing the data, click "Select All Sheets," then "Move or Copy" them to the new blank workbook.  The import into Sage 500 is successful when
    we do that.  However, we need to save the workbook with the updated import information returned by Sage 500, so we must also do a "Save As" for the new workbook, assigning the same file name as the original data file, overwriting
    it.  This makes what used to be a simple procedure quite cumbersome, and we fear the risk of data loss may be significant.
    Is there any way to make this process work the way it does in earlier versions of Excel that support MDI (Multiple Document Interface)?

    Is there any way to make this process work the way it does in earlier versions of Excel that support MDI (Multiple Document Interface)?
    At a glance, it seems the answer might be...No.
    Note                  
    There is no MDI compatibility option in Excel 2013.
    From: http://msdn.microsoft.com/en-us/library/office/dn251093.aspx
    You should contact Sage, to see if they have solutions/suggestions, but I think it will require Sage to re-develop the Dataporter Add-in ?
    Don
    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer", where applicable.
    This helps the community, keeps the forums tidy, and recognises useful contributions. Thanks!)

  • Problem with Excel 2013 TaskPane

    Hello,
    I got problem with TaskPane on Excel 2013. With Excel 2007 and 2010 my program works perfectly.
    I'm opening a workbook and making custom ribbon, but my workbook is hided and the problem comes that first time i can see TaskPane but after any other workbook opening and closing i can't show TaskPane because Globals.ThisAddIn.SarasuTaskPane.Visible
    = true don't showing me TaskPane. Actual it's showing but we can't see it because it's hided with workbook, and if i unhide workbook i can see and use it. But i need my main workbook to be not visible for all time and users must see TaskPane.
    I will try write step by step.
    1. I'm launching .exe which creating excel object
    2. With Excel object I'm opening .xlsm which sheets are protected and not visible, and Run my Sub
    3. That Sub loads my COM AddIn, and opens another .xlsm file (at the moment there are 2 .xlsm files opened)
    4. My Add-in creates TaskPane, and TaskPane adds on my first .xlsm file(i noticed), and it's fine i can see it. But then i try some of my functions which sets TaskPane visible - false, and opens another .xlsx file then closes it, and trying to do TaskPane visible
    - true no errors but also no TaskPane, then i Manually unhide my first Workbook i can see the TaskPane, when i hide it manualy - TaskPane hides too.. and this only on Excel 2013.
    Any ideas to solve this? As i mention before with Excel 2007 and 2010 no problems it's works perfectly.
    sincerely,
    Julius

    I have used you code to hide a panel , it works fine
    Maybe my first post was incorrectly written. I will try write step by step.
    1. I'm launching .exe which creating excel object
    2. With Excel object I'm opening .xlsm which sheets are protected and not visible, and Run my Sub
    3. That Sub loads my COM AddIn, and opens another .xlsm file (at the moment there are 2 .xlsm files opened)
    4. My Add-in creates TaskPane, and TaskPane adds on my first .xlsm file(i noticed), and it's fine i can see it. But then i try some of my functions which sets TaskPane visible - false, and opens another .xlsx file then closes it, and trying to do TaskPane
    visible - true no errors but also no TaskPane, then i Manually unhide my first Workbook i can see the TaskPane, when i hide it manualy - TaskPane hides too.. and this is only on Excel 2013.

  • Import data from excel 2013 workbook issue,is it a bug ?

    When I use powerquery to import data from excel 2013 workbook An unexpected error occurred.Other editions no problem.

    I‘m sure this is a bug.I'm option in default language set to English.Saved the file and use powerquery import it.Excle worked fine.
    I'm option in default language set to simple chinese.Saved the file and use powerquery import it.An error occurred.

  • Excel 2010 workbook crashing Excel 2013

    We have someone who created a workbook in Excel 2010 and when we open it in Excel 2013 it will crash. You can open the doc and look at it, but once you start trying to do anything in it, after a random time period, it will crash. Also if you try to resave
    the document it will crash every time, no matter how long you've been in the doc.
    Is there any way we can track down what in the doc might be causing this? I've tried it on several different systems with excel 2013, a few of which have SP1 installed already and it does the same thing. Any suggestions?

    Hi Jcasteel,
    Could you please give us more information about this workbook?
    Any Macros or formulas in this file? Does this file have any links to other files? Try to move VBA code or links manually to narrow down this issue(You can change this workbook in excel 2010). If it contains multiple worksheets ,open them separately
    to address this issue.
    In addition, have you ever try the general methods? e.g.
    1.Open the workbook using the 'open and repair' feature(Start Excel->On the File menu-> click Open->In the Open dialog box, select the file that you want to open->Click the arrow on the Open button, and then click Open and Repair )
    2.Start excel in Safe Mode(Press and hold the CTRL key, and then click the name of the Microsoft Office program that you want to run)
    Also if it is convenient for you, you can share your workbook with us .
    Wind Zhang
    TechNet Community Support

  • Creation of PDF from Excel 2013 - problem with black color

    Hi,
    I am a publisher of crossword magazine and I use Excel to write crosswords. Then I create PDF's and import them into InDesign.  
    In past I used Adobe printer and it works fine with Excel 2000 and 2010 (only these two versions I used in past) Now I switched to Excel 2013 and when I use Adobe printer to print crosswords into PDF problem occurs with lines done in Excel (insert - shapes - line). I use black color for these lines but in PDF they appears as rich black (TIC 300%). Why it is not 100% black? I know that Excel works in RGB but in past I was always able to change settings in printer profiles (Adobe printer) to reach 100 % black without CMY colors. Now I have no idea. I attached picture of pdf how it looks in Adobe Acrobat in Outpur preview.
    Thank you in advance for any advice

    These are tough issues I suspect and the answer you need is probably trivial (it is finding it). I will make some suggestions, but I have no idea if any will work.
    -  In the printer under the Properties>Layout>Advanced>print quality, I use 300 dpi (default is 1200).
    - Under the printer preferences>settings>edit the settings file, I use again 300 dpi (default is 1200 dpi).
    These may not fix your issue, but migth be worth a try. You could also try using the preflight script to change to gray-scale. It may not make any changes, but again may be worth a try.
    All I am trying to suggest are the things I would be looking at. Maybe they will lead you someplace. Others may be by with better suggestions in time.

  • SAP Office Integration Excel 2013 problem - dummy window pops up with inplace

    Hi experts all around the globe,
    we are facing a strange problem by some of our users since they have installed Excel 2013 on their PCs. An annoying Excel sheet pops up while generating an excel file in the background.
    They are working with several Y (or Z if you like it better so) transactions, and create multiple Excel files (Excel.Sheet.8 -> .xls) in the background. The programs are using Office Integration (interfaces I_OI_CONTAINER_CONTROL and I_OI_DOCUMENT_PROXY) to create the files.
    Method OPEN_DOCUMENT is called with the parameter OPEN_INPLACE, modified, and then closed with the CLOSE_DOCUMENT method, then saved with SAVE_DOCUMENT_TO_URL. The document gets only assigned to a dummy container, this means under normal circumstances the user shouldn't see anything - the file gets created, modified and stored in the background - end of the story. The programs are like 10 years old, and have been doing good since then.
    Now some of our users reported, that they have an issue when generating Excel files with those programs. We have investigated / debugged, and here is the thing: in several cases when the method OPEN_DOCUMENT is called, an empty worksheet pops up (see attached screenshot). It also gets in focus, and then in 1 sec is it closing again (as the CLOSE_DOCUMENT is called). This is really annoying when the user has to generate hundreds of Excel sheets (it is quite often the case). The window gets opened and closed with every single file that gets created.
    We have tried to identify the problem, but it is user independent, the SAP GUI, Office and Windows versions seem to be all the same - though it appears by some users. The most of us work with SAP GUI 730 Patch level 4, but upgrade to Patch level 9 has also not solved the problem. We have found the notes 1908528 and 1804535. They address similar problems but not exactly the same. We think it has something to do with incompatibility of the releases, or simply an Office / SAP setting we could not think of.
    Has someone encountered the same? Any ideas?
    Your help is greatly appreciated.
    Boldi

    Hello Daniel,
    thank you very much for your reply, it is really appreciated.
    We have SAP GUI 7.30 Version 7300.3.9.1084 Build 1496147 Patch Level 9 on the test machine. This one should be the latest available version, am I right?
    The issue is a little bit different from the ones described in the SAP notes you suggested. The data is getting "correctly" displayed inplace, but Excel is also getting called up in the same time, and an additional emtpy sheet is displayed, which gets in the focus, disturbing the user. It is just like described in the SAP notes 1425448 and 1567380
    To 1425448 (Solution Point 2 below): this is our standard setting, and it does not help us.
    To 1567380 (Prerequisites): there is no macro in our sheet.
    We could reproduce the issue with the standard report SAPRDEMO_SPREADSHEET_INTERFACE (this is the one suggested in SAP note 1908528 - "Verifying that Excel inplace functionality is working correctly"). The SAP GUI overtakes the focus after a while, as described in the SAP note 1567380, but the empty sheet is active at first, and it is a little bit more than annoying.
    How is it on your side, could you please run the standard report (EXCEL, checkbox for inplace set, then Enter) to confirm that the problem exists?
    Thanks a lot in advance and have a nice day!
    Boldi

  • Problems with black color creating PDF from Excel 2013

    Hi
    I want to create PDF from Excel 2013 using Adobe Acrobat distiller. When I do so I have problem with black which is 300 percent black instead of 100K. Problem is only with drawed lines from Excel's symbol menu (text is fine).
    I use Acrobat 9 Pro and few days ago switched from Office 2000 to 2013.....and problems started.
    Office 2000 and Acrobat 9 Pro worked ok and everything including drawed symbols like lines or squares were 100K black in PDF. Now in the case of Excel 2013 it is not so but when I use export function included in Excel and export file to PDF output is 100K. I am not sure if this kind of export is good for me. I use PDF's as inputs to InDesign. So I would like to have more control when create PDF from excel. But in Excel setup I can choose standard and minimum size and that is all.
    I imported Adobe PDF Settings from computer where these settings worked with Excel 2010 but they do not do same job for me in combination with Excel 2013 (I have 300 black).
    To explain my workflow:
    I am a publisher of crossword magazine and I use Excel to write crosswords. Then I create PDF's and import them into InDesign.   
    Should I use internal export included in Excel 2013? Are these PDF's ok for working in InDesign and finally for print purposes?
    Or If you have any suggestion how to create PDF via Adobe Acrobat distiller setup (which I prefer) please give me advice.
    Thank you in advance
    Juraj

    These are tough issues I suspect and the answer you need is probably trivial (it is finding it). I will make some suggestions, but I have no idea if any will work.
    -  In the printer under the Properties>Layout>Advanced>print quality, I use 300 dpi (default is 1200).
    - Under the printer preferences>settings>edit the settings file, I use again 300 dpi (default is 1200 dpi).
    These may not fix your issue, but migth be worth a try. You could also try using the preflight script to change to gray-scale. It may not make any changes, but again may be worth a try.
    All I am trying to suggest are the things I would be looking at. Maybe they will lead you someplace. Others may be by with better suggestions in time.

  • Power View not showing on opening workbook in Excel 2013

    When I re-open an Excel 2013 SP1 workbook with a Power View sheet, the Power View is coming up as disabled. To get it back, I have to insert a new Power View sheet. This then starts up PV and the sheet is shown properly.
    Does anyone know how to get PV to show on start-up so that I don't have to insert a new PV sheet each time?
    Paul

    Hi Paul,
    Based on my research, I think this issue is caused by having turned off the Power View add-in from Excel Options. To troubleshoot this issue, we can refer to the following steps:
    Set the Formula bar as visible in your ribbon
    Enable add-ins of power view, please go to  File>Options>Add-Ins
    In the Manage box, click the drop-down arrow > COM Add-ins > Go.
    Check the Power View check box > OK. 
    If this issue still exists, please try to repair Office in Control panel>Program and features>Right click Office 2013 and repair.
    The following document about Create a Power View sheet in Excel 2013 is for your reference:
    http://office.microsoft.com/en-in/excel-help/create-a-power-view-sheet-in-excel-2013-HA102899553.aspx
    Hope this helps.
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

Maybe you are looking for

  • Error when logging into Apple/Support/Discussions

    This happens with every browser (Firefox, Camino, & Safari). I am using the default auto-login feature of each browser. This has been happening for about a week. Anyone experiencing this? Not that much a big deal... but... bug? "ERROR: An error has o

  • My Apple devices wont download apps anymore. Please help!

    I have the iPod Touch 5th generation and iPad 2nd generation. Since about a week ago, I haven't been able to download any apps on either device. In the app store, I'll tap 'Install', it'll ask for my apple ID, the usual. It loads untill it say 'Open'

  • Message Mapping of type ABAP Class not being shown

    Hi all, I have been trying to follow the given blog: /people/ravikumar.allampallam/blog/2005/02/10/different-types-of-mapping-in-xi Even after doing the changes mentioned in the blog, i do not see the ABAP Class in the list of Message Mapping types.

  • How do I get the colour board to show percentages?

    Underneath the colour corrections, I am unable to see a reference. How do I view this? e.g. when moving the mid-tones spot, I do not get a numerical reference underneath the board? All colour grading tutorials show a numerical tablet underneath the c

  • How to trigger idocs(outbound)

    Hi SapAll. here i just created a sample idoc to file scenario in SAP-NETWEAVER-XI/PI7.0 ,i just want to know on how to trigger the list of idocs that i explained below at sender SAP-R/3 side  . MATMAS.MATMAS05 SRVMAS.SRVMAS01 CREMAS.CREMAS04 ACC_EMPL