In VB.NET check for changes in a file launched with process.start()

后端 未结 3 1980
春和景丽
春和景丽 2021-01-28 16:59

I\'m developing a vbnet/c#.NET based application that opens files with different applications(excel, word, etc).

The application is launched using Dim app As Proce

3条回答
  •  难免孤独
    2021-01-28 17:32

    For office applications use Office Interop Assemblies, not Process.Start to start and control them. Here is an example code for Excel (in VB.NET). You should add Microsoft.Office.Interop.Excel.dll to the project references in order for this to work.

       oExcel = New Microsof.Office.Interop.Excel.Application
       oBook = oExcel.Workbooks.Open(filepath)
       'Do your stuff
       oBook.Close 'This will trigger the application native prompt if the document was modified
       oExcel.Quit()
    

    For other programs it depends much on a program

提交回复
热议问题