How to open excel file from C # / WPF in full screen?

I am currently opening files from my C # / WPF application using

System.Diagnostics.Process.Start("C:\ .... "); 

Whether the application window is in full screen, etc., depends on the state in which the previous instance of the application was when it was closed (for example, if it was closed in full screen, it opens the full screen of the new instance).

What I'm trying to do is open the file in Excel and make it fullscreen. I looked at the command line keys for Excel, it seemed quite limited, since I can not modify excel files by adding Application.DisplayFullScreen = True to the VBA module.

Edit: it is unclear, but I wanted to open it in full screen mode (without tape, etc.), and not maximize it.

Edit2: The key sequence will be alt+v,u . Looking for a way to use SendKeys to send a sequence of keys to an excel window

+6
source share
2 answers

It looks like you can use SendKeys.

http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx

Edit: this code worked for me

Mandatory #include System.Windows.Forms and all that is needed.

 [DllImport("user32.dll")] static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); public void Go() { Process excel = new Process(); excel.StartInfo.FileName = @"C:\Test.xlsx"; excel.Start(); // Need to wait for excel to start excel.WaitForInputIdle(); IntPtr p = excel.MainWindowHandle; ShowWindow(p, 1); SendKeys.SendWait("%(vu)"); } 

See this SO post:

How to open a PDF file using Foxit / Adobe in full screen?

+4
source

Excel interaction may work for you ... this is pretty annoying for the code, but you can do almost anything with it that the user can do in excel for himself.

This is an overview of how to use it.

http://www.dotnetperls.com/excel

This suggests that you can use the Application.DisplayFullScreen property to get it in full screen

http://msdn.microsoft.com/en-us/library/office/aa168292(v=office.11).aspx

+4
source

Source: https://habr.com/ru/post/959197/


All Articles