473,385 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

VSTO - Word Document is Saved Empty

Hi everyone,

I have a problem here. Here is my code:

Expand|Select|Wrap|Line Numbers
  1.         private void wa_DocumentBeforeSave(Word.Document Doc, ref bool SaveAsUI, ref bool Cancel)
  2.         {
  3.             Cancel = true;
  4.             SaveAsUI = false;
  5.  
  6.             SaveDocumentAtSharePoint(Doc);   
  7.         }
  8.  
  9.         private void SaveDocumentAtSharePoint(Word.Document Doc)
  10.         {
  11.             object FileName = @"C:\temp\WordFile.doc";
  12.             object FileFormat = Word.WdSaveFormat.wdFormatDocument;
  13.             object LockComments = false;
  14.             object AddToRecentFiles = false;
  15.             object ReadOnlyRecommended = false;
  16.             object EmbedTrueTypeFonts = false;
  17.             object SaveNativePictureFormat = true;
  18.             object SaveFormsData = true;
  19.             object SaveAsAOCELetter = false;
  20.             object Encoding = Core.MsoEncoding.msoEncodingUSASCII;
  21.             object InsertLineBreaks = false;
  22.             object AllowSubstitutions = false;
  23.             object LineEnding = Word.WdLineEndingType.wdCRLF;
  24.             object AddBiDiMarks = false;
  25.  
  26.             Doc.SaveAs(ref FileName,
  27.                                ref FileFormat, ref LockComments, ref missing,
  28.                                ref AddToRecentFiles, ref missing,
  29.                                ref ReadOnlyRecommended,
  30.                                ref EmbedTrueTypeFonts, ref SaveNativePictureFormat,
  31.                                ref SaveFormsData, ref SaveAsAOCELetter,             
  32.                               ref Encoding, ref InsertLineBreaks, ref AllowSubstitutions,  
  33.                                ref LineEnding, ref AddBiDiMarks);
  34.  
  35.             Doc.Saved = true;
  36.         }
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
Jan 25 '08 #1
1 2184
I solved the problem, if you turn the AllowSubstitutions to true the file will be saved with its content.

Hi everyone,

I have a problem here. Here is my code:

Expand|Select|Wrap|Line Numbers
  1.         private void wa_DocumentBeforeSave(Word.Document Doc, ref bool SaveAsUI, ref bool Cancel)
  2.         {
  3.             Cancel = true;
  4.             SaveAsUI = false;
  5.  
  6.             SaveDocumentAtSharePoint(Doc);   
  7.         }
  8.  
  9.         private void SaveDocumentAtSharePoint(Word.Document Doc)
  10.         {
  11.             object FileName = @"C:\temp\WordFile.doc";
  12.             object FileFormat = Word.WdSaveFormat.wdFormatDocument;
  13.             object LockComments = false;
  14.             object AddToRecentFiles = false;
  15.             object ReadOnlyRecommended = false;
  16.             object EmbedTrueTypeFonts = false;
  17.             object SaveNativePictureFormat = true;
  18.             object SaveFormsData = true;
  19.             object SaveAsAOCELetter = false;
  20.             object Encoding = Core.MsoEncoding.msoEncodingUSASCII;
  21.             object InsertLineBreaks = false;
  22.             object AllowSubstitutions = false;
  23.             object LineEnding = Word.WdLineEndingType.wdCRLF;
  24.             object AddBiDiMarks = false;
  25.  
  26.             Doc.SaveAs(ref FileName,
  27.                                ref FileFormat, ref LockComments, ref missing,
  28.                                ref AddToRecentFiles, ref missing,
  29.                                ref ReadOnlyRecommended,
  30.                                ref EmbedTrueTypeFonts, ref SaveNativePictureFormat,
  31.                                ref SaveFormsData, ref SaveAsAOCELetter,             
  32.                               ref Encoding, ref InsertLineBreaks, ref AllowSubstitutions,  
  33.                                ref LineEnding, ref AddBiDiMarks);
  34.  
  35.             Doc.Saved = true;
  36.         }
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
Jan 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Adam Knight | last post by:
I am trying to create a word document via asp. I keep getting this error: Server object, ASP 0178 (0x80070005) The call to Server.CreateObject failed while checking permissions. Access is...
3
by: Andy | last post by:
I am trying to do the following from an ASP.NET Web Application (C#). User fills out a form. The program takes those answers and merges them with a WORD document. I have tried the few examples...
8
by: Joachim | last post by:
Hi, I want to try call/run Ms. Word via my VB.Net First I added reference : Microsoft Word 11.0 Object Library. Then I got 2 references in my reference list : Word and Microsoft.Office.Core When...
13
by: Howard Kaikow | last post by:
I just visited the MSFT web site and saw the comparison/pricing of the different VS 2005 versions. I was looking for a statement of the system requirements for VS Pro and VSTO, could not find. ...
3
by: tigrrgrr42 | last post by:
I am working(vb.net03and05) with word documents stored in a sql db and I am currently bringing them from a byte array into a temp file to pop into word and make word do its thing as a com object. ...
7
by: Dave | last post by:
Apologies for the newbie question. I have created a vb.net program for my company that is designed to work with Word Templates (about forty of them that we commonly use) that are selected by the...
2
by: Le | last post by:
Folks, I'm trying to do some office automation using VSTO 2005. I've verified that ..Net Programmability Support is installed for every MS Office application and Microsoft Forms 2.0 .Net...
0
by: Niyazi | last post by:
Hi, I created application that store the data in SQL SERVER that reside on network. The client also use this application to access the resources provided with application. But is the client want...
12
by: Steve | last post by:
I've been building an application that will merge fields in a text file with a word template, save the resulting word file out to the user's hard drive, and then email the file as an attachment. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.