473,588 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repost: Word Automation

I am attempting to insert an existing document into another existing
document. When I insert the section break where I want the file insertion to
take place, no matter what type of section break I use;
wdSectionBreakC ontinuous; wdSectionBreakO ddPage; wdSectionBreakE venPage; or
wdSectionBreakN extPage, incidently, the one that I want, it always results
in a continuous break.

It works great for all breaks other than Section breaks. It's only when
using a Next, Odd, or Even Section Break that the problem exists. I have
also tried using the integer values for the constants (2,3,4,5), but to no
avail.

Can anyone shed light on this item?

Thanks in advance,
--
Bill Cooter
bc*****@hotmail .com
Nov 16 '05 #1
2 3006
Hi Bill Cooter,

Is this what you want? I am not that sure.

Code:

object oMissing = System.Reflecti on.Missing.Valu e;
object oEndOfDoc = "\\endofdoc ";

Word._Applicati on oWord;
Word._Document oDoc;
oWord = new Word.Applicatio n();
oWord.Visible = true;
oDoc = oWord.Documents .Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
Word.Range wrdRng = oDoc.Bookmarks. get_Item(ref oEndOfDoc).Rang e;
object oCollapseEnd = Word.WdCollapse Direction.wdCol lapseEnd;
object oSection = Word.WdSectionS tart.wdSectionN ewPage;
wrdRng.Collapse (ref oCollapseEnd);
wrdRng.InsertBr eak(ref oSection);
wrdRng.Collapse (ref oCollapseEnd);
wrdRng.InsertAf ter("This is Page 2");
wrdRng.InsertPa ragraphAfter();
wrdRng.Collapse (ref oCollapseEnd);
wrdRng.InsertBr eak(ref oSection);
wrdRng.Collapse (ref oCollapseEnd);
wrdRng.InsertAf ter("This is Page 3");
wrdRng.InsertPa ragraphAfter();

Hope it helps. Correct me if i am wrong! Cheers.
--
Regards,
Chua Wen Ching :)
"Bill Cooter" wrote:
I am attempting to insert an existing document into another existing
document. When I insert the section break where I want the file insertion to
take place, no matter what type of section break I use;
wdSectionBreakC ontinuous; wdSectionBreakO ddPage; wdSectionBreakE venPage; or
wdSectionBreakN extPage, incidently, the one that I want, it always results
in a continuous break.

It works great for all breaks other than Section breaks. It's only when
using a Next, Odd, or Even Section Break that the problem exists. I have
also tried using the integer values for the constants (2,3,4,5), but to no
avail.

Can anyone shed light on this item?

Thanks in advance,
--
Bill Cooter
bc*****@hotmail .com

Nov 16 '05 #2
Chua,

I found my problem, but with your help. It was the way in which I was
setting columns in Page Setup. You proved to me that the problem was with my
code, and not a bug. Thank you for your help.

Bill

"Chua Wen Ching" <ch************ @nospam.hotmail .com> wrote in message
news:B4******** *************** ***********@mic rosoft.com...
Hi Bill Cooter,

Is this what you want? I am not that sure.

Code:

object oMissing = System.Reflecti on.Missing.Valu e;
object oEndOfDoc = "\\endofdoc ";

Word._Applicati on oWord;
Word._Document oDoc;
oWord = new Word.Applicatio n();
oWord.Visible = true;
oDoc = oWord.Documents .Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing); Word.Range wrdRng = oDoc.Bookmarks. get_Item(ref oEndOfDoc).Rang e;
object oCollapseEnd = Word.WdCollapse Direction.wdCol lapseEnd;
object oSection = Word.WdSectionS tart.wdSectionN ewPage;
wrdRng.Collapse (ref oCollapseEnd);
wrdRng.InsertBr eak(ref oSection);
wrdRng.Collapse (ref oCollapseEnd);
wrdRng.InsertAf ter("This is Page 2");
wrdRng.InsertPa ragraphAfter();
wrdRng.Collapse (ref oCollapseEnd);
wrdRng.InsertBr eak(ref oSection);
wrdRng.Collapse (ref oCollapseEnd);
wrdRng.InsertAf ter("This is Page 3");
wrdRng.InsertPa ragraphAfter();

Hope it helps. Correct me if i am wrong! Cheers.
--
Regards,
Chua Wen Ching :)
"Bill Cooter" wrote:
I am attempting to insert an existing document into another existing
document. When I insert the section break where I want the file insertion to take place, no matter what type of section break I use;
wdSectionBreakC ontinuous; wdSectionBreakO ddPage; wdSectionBreakE venPage; or wdSectionBreakN extPage, incidently, the one that I want, it always results in a continuous break.

It works great for all breaks other than Section breaks. It's only when
using a Next, Odd, or Even Section Break that the problem exists. I have
also tried using the integer values for the constants (2,3,4,5), but to no avail.

Can anyone shed light on this item?

Thanks in advance,
--
Bill Cooter
bc*****@hotmail .com

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1640
by: R Reyes | last post by:
Hi, no one answered so I thought reposting would get this some attention... What is the best way to manipulate MSOffice programs? I understand that regular web pages do not have certain permissions (because of safety measures) to do things like open up MS word/excel programs, for example, from a web site. Usually an activex control must be installed first I think? What I need is a strategy for the best way to open up word/excel...
1
12070
by: mickeydisn | last post by:
Sub: C++ Word automation Extract text hello. I want extact text form a word document using a visual c++ programme. I have see a lot of documentation. and my analysis is that I must use a "word automation". I have foud a lot of exemple to use it but I need your precious help to
12
5514
by: Cheval | last post by:
Has anyone had any problems with inter-office automation between MS Word and MS Access in Office 2003? I have recently installed office 2003 in a new folder and have left the older office 2000 and office XP components installed. ie I have word/access/excel 2k/xp/2003 installed. I tried to do a usual access 2k to word 2k automation yet I get the error "Automation Error" "ClassFactory cannot supply requested class" when on late binding try...
6
3944
by: Colleyville Alan | last post by:
I have an application that has an Access table that stores the locations of slides in a Powerpoint file. This used to work fine when there were about 4 files and 200 slides. The database would open all four PPT files at once, and would loop through queriers for ever client and create custom presentations. Now there are 8 files, nearly 500 slides and the computer is bogging down with trying to open them all at once. I know that Access...
2
2607
by: kids | last post by:
Does anybody know any reason which could cause Ms. word automation to crash? I try to call word automation to open a document and use find and replace function. For some reason it works but I don't know why it crash some time.
4
7665
by: Daniel | last post by:
Hello, i have a problem with the word automation from c#. First, i want to mention, that i don't have any dependencies from word in my c#-project, i want to use the system.reflection model to handle the automation. So, i'm using the following code to create a new word document: ---Code---
4
11125
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone done this? Does it seem possible? I followed the instructions from a sample on the Microsoft knowledge base but it only seems to work when creating a VB.NET Windows .EXE, not an VB.NET ASP app.
5
2515
by: Daniel Walzenbach | last post by:
Hi, I need to know how I could populate a word file from within ASP.NET and stream it out to some user (I can rely on all users have at least Word XP installed). The preferable solution would be to have a word template on the server which is populated in the asp.net application and then streamed out to the user. Also acceptable would be to open a template on the client's computer using automation and fill this file (if this is possible)....
10
3273
by: cj2 | last post by:
I open a word template in VB and add values to the bookmarks then save the document as as pdf. When I then go to close the document it pops up a save as dialog box. It's already saved the document in pdf and that is all I want done with it. How can I tell it to close the file without prompting me for anything? For Each row As DataRow In myDt.Rows Dim objWord As Application Dim objDoc As Document objWord =...
0
7857
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
8220
Oralloy
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...
1
7981
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
8222
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
6632
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...
1
5723
isladogs
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...
0
5396
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
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2367
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.