Paul L

Paul L

  • NA
  • 5
  • 1.1k

Switching zoom and view (page break preview) in VS C# 2008/O2003

Jun 26 2020 4:35 AM
I've tried quite a bit of things in the interop, some just don't show up in VS that they do in the interop docs. The customer has Office 2003. I got the excel filled in, but I want to make sure it's in PBP and zoomed is right. I have yet to get that to work after a number of tries. Maybe you can make more sense of what i'm trying to do here. I'm (relitively) new to c#, but have a but have done other programming in the past. Mainly PHP, some VB.net. There is still a lot of the basics of c# I simply don't get. Here is my code
 
String ExcelFile = Directory.GetCurrentDirectory() + "\\WORK ORDER 1 EXCEL.xls";
  1. using System.Text;  
  2. using System.Xml;  
  3. using System.Windows.Forms;  
  4. using Excel = Microsoft.Office.Interop.Excel;  
  5. using System.Reflection;  
  6. using System.IO;  
  7. String ExcelFile = Directory.GetCurrentDirectory() + "\\WORK ORDER 1 EXCEL.xls";  
  8. Excel.Application xlApp;  
  9. Excel._Workbook oWB;  
  10. Excel._Worksheet oSheet;  
  11. Excel.Range oRng;  
  12. Excel.Workbooks oWBS = null;  
  13. Excel.Sheets sheets = null;  
  14. xlApp = new Excel.Application();  
  15. xlApp.Visible = true;  
  16. oWB = xlApp.Workbooks.Open(ExcelFile, 0, 1, Type.Missing, Type.Missing,  
  17. Type.Missing, Type.Missing, Type.Missing, Type.Missing,  
  18. Type.Missing, Type.Missing, Type.Missing, Type.Missing,  
  19. Type.Missing, Type.Missing);  
  20. sheets = oWB.Sheets;  
  21. oSheet = (Excel._Worksheet)oWB.ActiveSheet;  
  22. ////oSheet.ViewMode = ViewMode.Preview;  
  23. oRng = (Excel.Range)oSheet.Cells[2, 41];  
  24. oRng.Value2 = "12345";  
I was looking into windows.view
 
but it does not contain view
 
https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.excel.window.view?view=excel-pia#Microsoft_Office_Interop_Excel_Window_View
 
Maybe it's the version i'm using. VS 2008 /w interop for office 2003 (though other than the page break preview issuek has been working)
 
I remember using com objects with VB.net a few years back. Nothing complicated like this
thank you