none
VSTO Excel bug: clipboard null after PageSetup modification RRS feed

  • Question

  • Hi,

    Found a bug in VSTO excel add-in.

    Version:

    Microsoft Visual Studio Premium 2012
    Version 11.0.61030.00 Update 4
    Microsoft .NET Framework
    Version 4.5.50938
    Installed Version: Premium

    VSTO 10.0.50903

    Problem:

    When you open two or more workbooks, and try to copy and "paste special" from one to antoher, clipboard gets cleared automatically in scenario when you try to alter PageSetup object using application event.

    Steps to reproduce:

    1. Create an empty Excel add-in project.

    2. Add event as in code below.

    3. Run Excel

    4. Ctrl+N spawn new excel

    5. Try to copy and paste special to another excel window.

    6. Clipboard is empty, copy failed...

    Regards,

    Bart

    Code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;
    using Excel = Microsoft.Office.Interop.Excel;
    using Office = Microsoft.Office.Core;
    using Microsoft.Office.Tools.Excel;
    
    namespace ExcelAddIn2
    {
    	 public partial class ThisAddIn
    	 {
    		  private void ThisAddIn_Startup(object sender, System.EventArgs e)
    		  {
    				this.Application.WorkbookActivate += Application_WorkbookActivate;
    		  }
    
    		  void Application_WorkbookActivate(Excel.Workbook Wb)
    		  {
    				foreach (Microsoft.Office.Interop.Excel.Worksheet item in Wb.Worksheets)
    				{
    					 item.PageSetup.LeftHeader = "&B Bold text &B";
    				}
    		  }
    
    		  private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
    		  {
    		  }
    
    		  #region VSTO generated code
    
    		  /// <summary>
    		  /// Required method for Designer support - do not modify
    		  /// the contents of this method with the code editor.
    		  /// </summary>
    		  private void InternalStartup()
    		  {
    				this.Startup += new System.EventHandler(ThisAddIn_Startup);
    				this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
    		  }
    
    		  #endregion
    	 }
    }
    



    Monday, January 19, 2015 12:39 PM

All replies

  • Hi Bart,

    I have tried to reproduce  issue, but failed .My steps are:

    1 New a project using the code and run it, create  workbook1.

    2. Ctrl +N ,create a new workbook,workbook2.

    3. insert a square shape in workbook1, copy it

    4.trun to workbook2, paste special as png,jpeg,gif,bitmap,..

    They all worked fine, pasted successfully. Did I miss something? Also, I have reset the margin during runtime, no same issue shows. My VSTO version also is 10.0.50903 . And My office is Office2010.

    Best Regards

    Lan


    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.

    Thursday, January 22, 2015 8:50 AM
    Moderator
  • We all have Office365 ProPlus 15.0.4569.1507 (32bit) - and this fails for everyone here.

    I will try Office2010, though it's irrelevant for my company....

    Regards,

    Bart

    Thursday, January 22, 2015 8:59 AM
  • Hi Bart,

    I have tested in my excel (both office 2010 and office 2013) ,copied a range, cell ,shape, and pasted it as a special form, only shape could make a successes,  but the cell and range failed in pasting, automatically and  manually altering the page layout, even though I did not have the application event . If you need to change the page layout, for now, there is no a best way to solve this, but as a temporary alternative, you can alter page layout in the event of WorkbookOpen.

    Meanwhile, I will involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Best regards

    Lan      

           


    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.


    Monday, January 26, 2015 3:32 AM
    Moderator
  • Hi,

    is there any update on this?

    We have the same problem.

    We have a vsto addin and if you access PageSetup, Excel clears the clipboard.

    As a workaround we save the clipboard before accessing the PageSetup and then restore clipboard.

    But now we have a problem that another program seems to block the clipboard so excel hangs forever.

    Thanks

    Mark


    Regards Mark


    • Edited by Wompi Tuesday, August 22, 2017 6:13 AM
    Tuesday, August 22, 2017 6:13 AM