I have a wpf window which should be opened beside an Excel window. Excel is opened and handled with Interop.Excel. In my Window i have a method, which should set the size of the excel window.
private void SetLayout()
{
Top = 0;
Left = 0;
Height = SystemParameters.WorkArea.Height;
((ConfiguratorWindowViewModel) DataContext).Manager.App.Height =
SystemParameters.WorkArea.Height;
((ConfiguratorWindowViewModel) DataContext).Manager.App.Left = Width;
((ConfiguratorWindowViewModel) DataContext).Manager.App.Width = SystemParameters.WorkArea.Width - Width;
}
In my Viewmodel I have a Manager which gives back the open Excel App (Office.Interop.Excel.Application). I can set the Height,Top,.. of my wpf window and it works fine, but not on the Excel window. How can i set the size of the Excel window beside my wpf window so that the two fill the complete screen together?
Edit:
I tried this, but it is also not working:
((ConfiguratorWindowViewModel) DataContext).Manager.App.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlNormal;
((ConfiguratorWindowViewModel) DataContext).Manager.App.ActiveWindow.Height = Screen.PrimaryScreen.Bounds.Height;
((ConfiguratorWindowViewModel) DataContext).Manager.App.ActiveWindow.Width = Screen.PrimaryScreen.Bounds.Width - Width;
Both sets the Height to a different value but not to the correct one, when i hardcode it like .Height=800;
it's also not working.
Unfortunately i can't post images to show you how it Looks and it should look like.
Edit:
The question is not the same as this one (How do I change another program's window's size?). I don't want to change the size of ah "foreign" application.