miserable frame behavior when copying and pasting

K

Keith G Hicks

I have 1 page a word doc (2000) with lots of frames and book marks. I
programatically put text in at the book marks via automation in foxpro.
That works fine. Don't need help with that at all. After the bookmarks are
all set, I do the following to copy and paste the entire doc into the front
of a different doc:

oWord.Selection().WholeStory && like CTRL+A
oWord.Selection().Copy() && like CTRL+C

oDocNew.Activate

oWord.Selection().Paste() && like CTRL+V


Basically this works fine except for one thing. The frames just go wherever
they want. I even tried setting the margins in the new doc to match those
in the first doc. Doesn't help. Things just scatter all over like they
have a mind of their own. I've also tried moving the frames to another page
in the doc they were originally in (manually), but they won't go to a
different page. What is up with these creatures? I would use text boxes
because you seem to hvae more control over their behavior, but you can't
"locate" a bookmark in a text box thru automation (bug or stupid design).

Any help would be appreciated.

Thanks,

Keith
 
C

Cindy Meister -WordMVP-

Hi Keith,
but you can't
"locate" a bookmark in a text box thru automation (bug or stupid design).
Sure you can. Problem is, you're trying to automate Word the same way a
user would work - and that always leads to problems. Just as with FoxPro,
you need to work with the OBJECT MODEL. For bookmarks:

o_doc.Bookmarks("TheName").Range.Text = "xyz"
The frames just go wherever they want.
It's really difficult to say what the problem might be, here, without
knowing a lot more about the setup of the two documents involved. My
instincts say that the problem probably has to do with the style
definitions in the two disparate files.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
K

Keith G Hicks

Thanks Cindy.
Style settings definitley were messign things up.
Same style names in 2 different docs had different settings.
When combining the 2 docs, it didnt' know what to do.
I haven't really worked much with styles.
That's fixed now.
Thanks again.

One other thing.
I know how to change the margins of the entire document in automation:

With oDocNew.PageSetup
.Orientation = 0
.BottomMargin = 0.5 * autoInchesToPoints
.TopMargin = .5 * autoInchesToPoints
.LeftMargin = .5 * autoInchesToPoints
.RightMargin = .5 * autoInchesToPoints
Endwith

But how do I change just 1 page.
The first page of my finished doc should have 1" margins and the subsequent
pages should have 0.5" margins.
If I run the above code just before the 2nd page is inserted (after the 1st
page is done) it changes the whole thing, not just the REST of the document.
How do I implement "Apply To" in the Page setup menu in code?

Thanks,

Keith
 
C

Cindy Meister -WordMVP-

Hi Keith,

Great :) Hope your project finishes with no more serious obstacles!
I figured it out.
You have to create sections and then set the page information for each
section.
Everything is good here. :)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top