Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

Any way to put a page break into a string?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ed - 05 Apr 2007 15:57 GMT
I'm parsing a huge text file into several smaller files.  I capture
the portion I want to make into a new file in a string, open a
TextStream object, and write the string plus a bit more.  (Code is
below.)  At certain points in the new file, I would like to insert a
page break.  I'm thinking I would have to use something like InStr to
find the bit that marks a new page, then insert the break into the
string at that point.  But can you do that in a string?  Or is there
another way to put a page break in a TextStream file?

Ed

Set docNew = fs.CreateTextFile(strNewDoc)
docNew.Write (strNew & vbCr & vbCr & _
   "This file created from archive files on " & _
   Format(Now, "dd mmm yyyy"))
Helmut Weber - 05 Apr 2007 16:29 GMT
Hi Ed,

try putting a chr(12) it the string.

But there is more to it.

See: http://tinyurl.com/244hwp

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Ed - 05 Apr 2007 21:32 GMT
Hi, Helmut.

> Hi Ed,
>
> try putting a chr(12) it the string.
>
> But there is more to it.

But only if I want something other than a plain page break?

I do not want a section brealk, just a page break.  So I can use
Replace(strDocText, strBreakText, strBreakText & Chr(12),
1,-1,vbTextCompare)  ???

Ed

> See:http://tinyurl.com/244hwp
>
[quoted text clipped - 5 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
Helmut Weber - 06 Apr 2007 09:27 GMT
Hi Ed,

>But only if I want something other than a plain page break?

yes, seems so.

Tested with:

Sub Macro4()
ActiveDocument.Range.Text = _
String(100, "x") & Chr(12) & String(100, "y")
End Sub

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Klaus Linke - 08 Apr 2007 17:54 GMT
It might work well, but I feel a bit queasy about it.
Especially since ^12 doubles as page break and section break.

Maybe better to make a more elaborate macro using
.InsertBreak(Type:=wdPageBreak) between the individual strings ...

Regards,
Klaus

> Hi Ed,
>
[quoted text clipped - 8 lines]
> String(100, "x") & Chr(12) & String(100, "y")
> End Sub
Helmut Weber - 08 Apr 2007 18:08 GMT
Hi Klaus,

>It might work well, but I feel a bit queasy about it.
>Especially since ^12 doubles as page break and section break.

indeed, though after executing

ActiveDocument.Range.Text = _
String(100, "x") & Chr(12) & String(100, "y")

there is no section break to be found.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Klaus Linke - 08 Apr 2007 21:04 GMT
You're probably right. I have frequently inserted text containing ^13 for
paragraph marks myself (even though I know better than to insert ^13 with a
Find/Replace), and never saw problems.

:-) Klaus

> Hi Klaus,
>
[quoted text clipped - 7 lines]
>
> there is no section break to be found.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.