473,797 Members | 3,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VSTO - Word Document is Saved Empty

9 New Member
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 2223
Juan Alvarez
9 New Member
I solved the problem, if you turn the AllowSubstituti ons 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
3959
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 denied to this object. I am running window 2000 professional with IIS 5.0 installed. I know it is a ntfs permissions error and that IUSR_ComputerName needs
3
1093
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 of launching word from my app and get ACCESS DENIED when the Word attempts to start. Once the merge is complete, the document gets saved and sent to the user to open and further edit if necessary. The initial merge part doesn't have to
8
11303
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 I typed : Dim objWord as Word.Application Dim objDocument as Word.Document I got an error (underline at Word.Application and Word.Document). What is actually happen ?
13
1952
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. Also, more details on the differences between VS Pro and VSTO. For example, can VSTO be used to create a DLL, in particular, a DLL that can be used as an ActiveX DLL with Office? In VSTO, other than the addition of the support for Office 2003...
3
4660
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. Is it possible to go straight from a byte array to document in word instead of a temp file? Also is there a way to change the save behaviour to notify my app to pickup a binary copy of the file or stream to save back to the sql db. Thanks in...
7
6252
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 user and populated (with info from an Access database) at run-time, then saved as Word documents. The program I have coded works fine -- it does what I need it to do. But it has two problems: (1) it runs very slowly, and (2) it does not seem to...
2
2796
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 Programmability Support is also installed under Office Tools through Office Setup. I've then installed VSTO 2005 (vstor.exe, http://www.microsoft.com/downloads/details.aspx?familyid=f5539a90-dc41-4792-8ef8-f4de62ff1e81&displaylang=en). After installing...
0
3233
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 to register new customer or companies they will enter the information in Windows Form and the program automaticaly creates the WORD document under specific folder under application path. Once the empty word file created than ask user if they want...
12
3458
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. The problem I'm having is that I can't delete the word file I saved at the end of the process due to the file being locked by the email process. It appears to take longer than the code takes to complete due to virus checking software that...
0
9537
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10246
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10209
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2934
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.