How to set excel file height and width based on screen size? RRS feed

  • Question

  • I am creating an Excel AddIn using VSTO. But I am not able to set height and width of Excel workbook dynamically.

    I am usingVS 2013 Excel 2010 Excel AddIn to create the AddIn.

    Please suggest ways to fix this issue.

    Wednesday, September 23, 2015 10:13 AM


  • Hi Animesh,

    >> How to set excel file height and width based on screen size?

    What have you tried? Did you get any error when you set excel application size? In my option, if the window is minimized, you could not set height and width due to they are read-only.

    Here is a simple code to set width and height.

                Excel.Application eApp = Globals.ThisAddIn.Application;
                eApp.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlNormal;
                //get screen width and heigth
                double screenWidth = Screen.PrimaryScreen.Bounds.Width;
                double screenHeight = Screen.PrimaryScreen.Bounds.Height;
                //set excel applciation width and height
                eApp.ActiveWindow.Left = 178.75;
                eApp.ActiveWindow.Top = 251.5;
                eApp.ActiveWindow.Width = 481.5;
                eApp.ActiveWindow.Height = 266.25;

    Best Regards,


    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, September 24, 2015 2:57 AM