2012-10-13 2 views
4

Word에서 PDF로 변환하는 변환기가 있습니다. 때로는 (일부 Word 파일의 경우) 배경에 소스 파일의 변경 내용 저장 -> YES NO CANCEL과 함께 메시지가 있지만 소스 파일에서 변경하지 마십시오. Word 파일에서 PDF 파일을 만들고 싶습니다. 아무 것도 바꾸지 않았습니다.Word를 PDF로 변환 - "저장"대화 상자를 비활성화하십시오.

이 프롬프트를 사용하지 않도록 설정하거나 자동으로 "아니요"로 설정할 수 있습니다. ?

// Create an instance of Word.exe 
     Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop.Word.Application(); 

     // Make this instance of word invisible 
     oWord.Visible = false; 

     oWord.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone; 

     oWord.Options.SavePropertiesPrompt = false; 
     oWord.Options.SaveNormalPrompt = false; 

     // Interop requires objects. 
     object oMissing = System.Reflection.Missing.Value; 
     object isVisible = true; 
     object readOnly = true; 
     object oInput = input; 
     object oOutput = output; 
     object oFormat = format; 

     // Load a document into our instance of word.exe 
     Microsoft.Office.Interop.Word._Document oDoc = oWord.Documents.Open(ref oInput, ref oMissing, ref readOnly, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref isVisible, ref oMissing, ref oMissing, ref oMissing, ref oMissing); 

     // Make this document the active document. 
     oDoc.Activate(); 

     // Save this document in Word 2003 format. 
     oDoc.SaveAs(ref oOutput, ref oFormat, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); 

     // Always close Word.exe. 
     oWord.Quit(ref oMissing, ref oMissing, ref oMissing); 
+0

이것은 워드 문서를 PDF로 변환하지 않고 워드 문서를 열고 ** 복사본을 Word 2003 (* .doc *) 형식으로 ** 저장합니다. – SliverNinja

+0

'형식'의 값에 따라 다릅니다. 이것이 wdFormatPDF (17)이면 PDF 파일을 만들어야합니다 (Office 2007 이상). – lesscode

답변

2

당신이 종료 할 수있는 첫 번째 인수로 잘못된 전달 시도해 봤어 : 여기

내 코드인가?