Using Word automation in C# I want to change the path which the next Save button will refer to

StackOverflow https://stackoverflow.com/questions/10848010

  •  12-06-2021
  •  | 
  •  

Frage

I have an application which creates and opens a document in Word. The user can modify the document and then save it again, but I don't want the user to be prompted via Word to save it in the location from which it was loaded - I want to set the path to which the document should be saved (if any) to another path.

I'm not using automation to show a Save as dialog - it's the Word "Save" button that will be pressed, and so I want to set some sort of global default "saves as" location.

War es hilfreich?

Lösung

In the end, quite simple but not very good naming on Microsoft's part (but let's be forgiving, they have a huge object there). Anyway, here's the code (where Application is the Word Application object defined in the Microsoft.Office.Interop.Word PIA):

Application.ChangeFileOpenDirectory("C:\\SampleFor\\StackOverflow");
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top