=============== ===
Problem Description
=============== ===
Following code is for
1. Load a Word Template called CustomerInfo1.d ot
2. CustomerInfo1.d ot is a normal Word Template with Form fields
3. After opening a document on that template, I put "2" in all the fields
for test
Problem is,
4. When I try to sav it, calling SaveAs, it just saves the "2"s and all the
other template contents, mainly text are gone.
=============== ===
Platform
=============== ===
-Win XP Pro
- Office 2000/ Word 2000
- Added Reference to "Microsoft Word 9.0 Object Library" in a C# Windows
Application
=============== ===
Others
=============== ===
Most of the MSDN samples seems to use Bookmarks. That's the way I will go
if there is no resolution
Please guide.
Appreciate that
Thanks
// =========== CODE BLOCK FOR YOUR REFERENCE STARTS ===========
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
using Word;
// !!! Other ASPX.CS codes !!!!
[STAThread]
static void Main()
{
System.Windows. Forms.Applicati on.Run(new Form1());
}
Word.Applicatio n wrdApp;
Word._Document wrdDoc;
Object oMissing = System.Reflecti on.Missing.Valu e;
Object oFalse = false;
Object oTrue = true;
Object oTemplate = "C:\\Projects\\ AutoWord\\Custo merInfo1.dot";
Object oFileName = "C:\\Projects\\ AutoWord\\Custo merInfo.doc";
private void button1_Click(o bject sender, System.EventArg s e)
{
try{
System.IO.File. Delete("C:\\Pro jects\\AutoWord \\CustomerInfo. doc");
System.IO.File. Create("C:\\Pro jects\\AutoWord \\CustomerInfo. doc");
}
catch(Exception ex){}
wrdApp = new Word.Applicatio n( );
wrdApp.Visible = true;
wrdDoc = wrdApp.Document s.Add(ref oTemplate, ref oMissing,ref
oMissing,ref oMissing);
foreach(Word.Fo rmField frmField in wrdDoc.FormFiel ds){
// Just for test I am Setting all form fields to 2
frmField.Result = "2";
}
// This save as saves only the 2s and wipes out the template content
wrdDoc.SaveAs(r ef oFileName ,ref oMissing ,ref oTrue ,ref oMissing,ref
oMissing,ref oMissing,ref oMissing,ref oMissing,ref oTru,ref oTrue,ref
oMissing);
wrdDoc.Close(re f oTrue,ref oFalse,ref oMissing);
wrdDoc = null;
wrdApp = null;
}
}
// =========== CODE BLOCK FOR YOUR REFERENCE ENDS=========== == 0 1537 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Neil |
last post by:
An article at http://news.com.com/2100-1012-991694.html?tag=fd_top states:
"XML would allow easier interchange of data generated in
Office documents with back-end systems or existing Web services."
As part of an Access 2000 application, I have to continually parse Word
documents and store the parsings in Access tables using Automation to
control Word and parse the document. Is there a way that XML would help with
that?
Thanks.
|
by: Ryan Muller |
last post by:
My company just upgraded from Access 97 to Access 2003 today and we are
having some issues in a database that generates a Word document from
information selected in a form.
Here is the code we were using without issue previous to the switch:
'Start Word and create a new doc from the template
Set objWord = CreateObject("Word.Basic")
objWord.AppMaximize "Microsoft Word", 1
objWord.FileNew Template:=StrTemplPath & "letter.dot"
|
by: Daniel Walzenbach |
last post by:
Hello,
I want to create a Word XML file based on the input users make in a VB.NET application. I imagine creating a template in Word and saving it as a XML file. I then want to fill the template (in my application) based on the user input. When the document gets opened there should be fields users can change but others should be prevented from beeing changed (I know that an "open" file format like XML can always be modified to allow...
|
by: Mikey |
last post by:
Sample VB .NET source code to create mailing labels or customized letters
using MS Word MailMerge
This VB .NET source code will start MS Word and call methods and set
properties in MS Word to execute a MailMerge to create mailing labels or
customized letters.
A label name known to MS Word MailMerge mailing label wizard may be used or
a template file containing the field names Line1 thru Line5 for each record
to be printed. If a...
|
by: Sudipto Sen |
last post by:
==================
Problem Description
==================
Following code is for
1. Load a Word Template called CustomerInfo1.dot
2. CustomerInfo1.dot is a normal Word Template with Form fields
3. After opening a document on that template, I put "2" in all the fields
for test
Problem is,
| |
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...
|
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...
|
by: jpr |
last post by:
Hello,
I have a form with a cbo which get's its data from a table. This combo
returns names of MS Word files in the following path:
C:\shares\files\*.dot
I would like to open these files (actually it should open a copy of the
template and not the dot file itself) using the OnChange event of my
cbo.
Is there a way or some code to help me? Thanks
|
by: jmar |
last post by:
I am updating a VB4.0 quote generation program to VB.net. The old
program takes user inputs, performs calculations, saves the data to
Access databases and uses Crystal Reports 5.0 to generate a quote. A
while back users obviously wanted to be able to edit/e-mail the quote
(these ancient Cyrstal 5.0 reports don't allow PDF creation) so I
modified the old VB4.0 code to allow users to save the Crystal Report
as Word document which they can...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |