简体   繁体   中英

Visual Studio Excel AddIn - VB.Net - ActiveWindow.Zoom Not Working

Could you please help me understand how to use "ActiveWindow" in vb.net? It's one of the items that I am having a difficult time converting from VBA to vb.net in Visual Studio. I want the ability to zoom to a specific level on the window/tab that is currently open in excel. Thanks for your help.

Dim ActiveWorksheet As Microsoft.Office.Interop.Excel.Worksheet =
    Globals.ThisAddIn.Application.ActiveWorkbook.Worksheets(1)

Dim Worksheet As Microsoft.Office.Tools.Excel.Worksheet =
    Globals.Factory.GetVstoObject(ActiveWorksheet)

    ActiveWindow.Zoom = 200

I don't understand what you are dimming the variable worksheet, but for the activeWindow and zooming, wouldn't this work?

Dim activWind As Microsoft.Office.Interop.Excel.Window
activeWind = Globals.ThisAddIn.Application.ActiveWindow
activWind.Zoom = 200

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM