How can I open an Excel file from C#/WPF in "Full Screen"?
c#, excel
Solution
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
Be sure to `#include System.Windows.Forms` and everything else that's 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 by using Foxit/Adobe in full screen mode?
Problem
Currently I'm 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 the previous instance of the application was in when it was closed (e.g. If it was closed when full screen, it opens a new instance full screen) What I'm trying to do is open a file in Excel and make it full screen. I looked into command line switches for Excel, seemed fairly limited since I can't modify the excel files by adding `Application.DisplayFullScreen = True` into a VBA module. Edit: Was unclear, but I meant to open it in Full Screen mode (no ribbon etc), not maximized. Edit2: The key sequence would be `alt+v,u`. Looking for a way to use `SendKeys` to send the key sequence to the excel window