VSTO - Word Document is Saved Empty

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Juan Alvarez
    New Member
    • Oct 2006
    • 9

    VSTO - Word Document is Saved Empty

    Hi everyone,

    I have a problem here. Here is my code:

    Code:
            private void wa_DocumentBeforeSave(Word.Document Doc, ref bool SaveAsUI, ref bool Cancel)
            {
                Cancel = true;
                SaveAsUI = false;
    
                SaveDocumentAtSharePoint(Doc);   
            }
    
            private void SaveDocumentAtSharePoint(Word.Document Doc)
            {
                object FileName = @"C:\temp\WordFile.doc";
                object FileFormat = Word.WdSaveFormat.wdFormatDocument;
                object LockComments = false;
                object AddToRecentFiles = false;
                object ReadOnlyRecommended = false;
                object EmbedTrueTypeFonts = false;
                object SaveNativePictureFormat = true;
                object SaveFormsData = true;
                object SaveAsAOCELetter = false;
                object Encoding = Core.MsoEncoding.msoEncodingUSASCII;
                object InsertLineBreaks = false;
                object AllowSubstitutions = false;
                object LineEnding = Word.WdLineEndingType.wdCRLF;
                object AddBiDiMarks = false;
    
                Doc.SaveAs(ref FileName,
                                   ref FileFormat, ref LockComments, ref missing,
                                   ref AddToRecentFiles, ref missing,
                                   ref ReadOnlyRecommended,
                                   ref EmbedTrueTypeFonts, ref SaveNativePictureFormat,
                                   ref SaveFormsData, ref SaveAsAOCELetter,             
                                  ref Encoding, ref InsertLineBreaks, ref AllowSubstitutions,  
                                   ref LineEnding, ref AddBiDiMarks);
    
                Doc.Saved = true;
            }
    The document is saved in the temp folder the Document is always Empty. I've done the same thing with Excel and the xls is saved correctly. I cant see what is causing this here.

    Help will be really apreciated,

    JMA
  • Juan Alvarez
    New Member
    • Oct 2006
    • 9

    #2
    I solved the problem, if you turn the AllowSubstituti ons to true the file will be saved with its content.

    Originally posted by Juan Alvarez
    Hi everyone,

    I have a problem here. Here is my code:

    Code:
            private void wa_DocumentBeforeSave(Word.Document Doc, ref bool SaveAsUI, ref bool Cancel)
            {
                Cancel = true;
                SaveAsUI = false;
    
                SaveDocumentAtSharePoint(Doc);   
            }
    
            private void SaveDocumentAtSharePoint(Word.Document Doc)
            {
                object FileName = @"C:\temp\WordFile.doc";
                object FileFormat = Word.WdSaveFormat.wdFormatDocument;
                object LockComments = false;
                object AddToRecentFiles = false;
                object ReadOnlyRecommended = false;
                object EmbedTrueTypeFonts = false;
                object SaveNativePictureFormat = true;
                object SaveFormsData = true;
                object SaveAsAOCELetter = false;
                object Encoding = Core.MsoEncoding.msoEncodingUSASCII;
                object InsertLineBreaks = false;
                object AllowSubstitutions = false;
                object LineEnding = Word.WdLineEndingType.wdCRLF;
                object AddBiDiMarks = false;
    
                Doc.SaveAs(ref FileName,
                                   ref FileFormat, ref LockComments, ref missing,
                                   ref AddToRecentFiles, ref missing,
                                   ref ReadOnlyRecommended,
                                   ref EmbedTrueTypeFonts, ref SaveNativePictureFormat,
                                   ref SaveFormsData, ref SaveAsAOCELetter,             
                                  ref Encoding, ref InsertLineBreaks, ref AllowSubstitutions,  
                                   ref LineEnding, ref AddBiDiMarks);
    
                Doc.Saved = true;
            }
    The document is saved in the temp folder the Document is always Empty. I've done the same thing with Excel and the xls is saved correctly. I cant see what is causing this here.

    Help will be really apreciated,

    JMA

    Comment

    Working...