473,513 Members | 2,425 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;
wdSectionBreakContinuous; wdSectionBreakOddPage; wdSectionBreakEvenPage; or
wdSectionBreakNextPage, 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 2997
Hi Bill Cooter,

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

Code:

object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc";

Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
object oCollapseEnd = Word.WdCollapseDirection.wdCollapseEnd;
object oSection = Word.WdSectionStart.wdSectionNewPage;
wrdRng.Collapse(ref oCollapseEnd);
wrdRng.InsertBreak(ref oSection);
wrdRng.Collapse(ref oCollapseEnd);
wrdRng.InsertAfter("This is Page 2");
wrdRng.InsertParagraphAfter();
wrdRng.Collapse(ref oCollapseEnd);
wrdRng.InsertBreak(ref oSection);
wrdRng.Collapse(ref oCollapseEnd);
wrdRng.InsertAfter("This is Page 3");
wrdRng.InsertParagraphAfter();

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;
wdSectionBreakContinuous; wdSectionBreakOddPage; wdSectionBreakEvenPage; or
wdSectionBreakNextPage, 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**********************************@microsof t.com...
Hi Bill Cooter,

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

Code:

object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc";

Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing); Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
object oCollapseEnd = Word.WdCollapseDirection.wdCollapseEnd;
object oSection = Word.WdSectionStart.wdSectionNewPage;
wrdRng.Collapse(ref oCollapseEnd);
wrdRng.InsertBreak(ref oSection);
wrdRng.Collapse(ref oCollapseEnd);
wrdRng.InsertAfter("This is Page 2");
wrdRng.InsertParagraphAfter();
wrdRng.Collapse(ref oCollapseEnd);
wrdRng.InsertBreak(ref oSection);
wrdRng.Collapse(ref oCollapseEnd);
wrdRng.InsertAfter("This is Page 3");
wrdRng.InsertParagraphAfter();

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;
wdSectionBreakContinuous; wdSectionBreakOddPage; wdSectionBreakEvenPage; or wdSectionBreakNextPage, 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
1629
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...
1
12060
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...
12
5505
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...
6
3936
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...
2
2603
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...
4
7647
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...
4
11118
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...
5
2493
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...
10
3263
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...
0
7386
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,...
1
7106
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...
0
5689
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,...
1
5094
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...
0
4749
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...
0
3236
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...
0
3226
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
459
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...

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.