static void word(MySettings settings)
{
Microsoft.Office.Interop.Word.ApplicationClass WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
object fileName = General.GetAppString("Resources") + General.GetAppString("DefaultWordTemplate");
object DestFilename = General.GetAppString("UserDocuments") + GlobalData.GetStudentInfo()[0].ToString().Trim() + "_" + GlobalData.GetUserName() + settings.FileExtension;
object readOnly = false;
object isVisible = false;
// Here is the way to handle parameters you don't care about in .NET
object missing = System.Reflection.Missing.Value;
// Make word visible, so you can see what's happening
WordApp.Visible = false;
// Open the document that was chosen by the dialog
Microsoft.Office.Interop.Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
// Activate the document so it shows up in front
aDoc.SaveAs(ref DestFilename, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
isVisible = true;
//Microsoft.Office.Interop.Word.Document aDoc = WordApp.Documents.Open(ref DestFilename, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
WordApp.Visible = true;
aDoc.Activate();
Documents[Impress.AppCount] = DestFilename.ToString();
}
static void OpenExcel(MySettings settings)
{
object missing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
excelApp.Visible = false;
Microsoft.Office.Interop.Excel.Workbook newWorkbook = excelApp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
string workbookPath = General.GetAppString("UserDocuments") + GlobalData.GetStudentInfo()[0].ToString().Trim() + "_" + GlobalData.GetUserName() + settings.FileExtension;
newWorkbook.SaveAs(workbookPath, missing, missing, missing, true, missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing, missing);
excelApp.Quit();
excelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
excelApp.Visible = true;
Microsoft.Office.Interop.Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath,
0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
Documents[Impress.AppCount] = workbookPath;
}
static void PowerpointWindow(MySettings settings)
{
PowerPoint.Application objApp;
PowerPoint.Presentations objPresSet;
PowerPoint._Presentation objPres;
string fileName = General.GetAppString("Resources") + General.GetAppString("DefaultPowerPointTemplate");
string DestFilename = General.GetAppString("UserDocuments") + GlobalData.GetStudentInfo()[0].ToString().Trim() + "_" + GlobalData.GetUserName() + settings.FileExtension;
//Create a new presentation based on a template.
objApp = new PowerPoint.Application();
objApp.Visible = MsoTriState.msoTrue;
objPresSet = objApp.Presentations;
objPres = objPresSet.Open(fileName, MsoTriState.msoCTrue, MsoTriState.msoTrue, MsoTriState.msoTrue);
objPres.SaveAs(DestFilename, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoTrue);
objApp.Visible = MsoTriState.msoTrue;
objApp.Activate();
Documents[Impress.AppCount] = DestFilename.ToString();
}
No comments:
Post a Comment