Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Columns spanning onto nextpage using InsertFile

Status
Not open for further replies.

murfeezlaw

Programmer
Jul 21, 2010
11
US
I'm using VBA to add a new document into the current open document. The title at the top of the new document that was inserted is being formatted in columns. How can i stop this? My code is below...

For Each ctrl In Me![sfmStateForms].Form.Controls
If TypeOf ctrl Is CheckBox And ctrl.Tag = "Mandatory" Then
If ctrl.Value = True Then
objWord.Selection.InsertFile "L:\Forms\" & Right(ctrl.Name, Len(ctrl.Name) - 3) & ".doc"
objWord.Selection.EndKey Unit:=wdStory
objWord.Selection.InsertBreak Type:=wdSectionBreakOddPage
End If
End If
Next

I tried different section breaks but it is keeping the formatting from the previous page. Any ideas?

TIA
Ted
 
The title at the top of the new document that was inserted is being formatted in columns."

Does that mean the inserted document is NOT in columns?

"I tried different section breaks but it is keeping the formatting from the previous page."

And does this mean the end of the document the inserted file is being inserted into IS in columns? Seems so.

If this is the case...turn off the columns before you insert the file. if you need to check if it IS in columns:
Code:
 If ActiveDocument.PageSetup.TextColumns.Count > 1 Then

Gerry
 
The inserted document does have columns but the title at the top of the page is only 1 column. i'm afraid if i turn columns off for the document it will affect the layout of the whole document.
 
i tried it anyway. it looks like it's working. i have to go thru the whole document to make sure all titles are ok.
 
i'm afraid if i turn columns off for the document it will affect the layout of the whole document. "

No, no, don't turn off columns for the whole document! Columns are toggled. If I understand correctly, the inserted file is:

1 column (for title)
x (2?) columns (for the rest of the document)

Yes?

If so, and if I also understand correctly, this is being done more than once (although you do not state this), then simply make it 1 column, insert the file.

The inserted file will be inserted into a 1 column state, and then by the fact that it is there now, become two column.



Gerry
 
Yeah that's exactly what I did. I thought if i changed it to 1 column before i inserted the document it would keep the whole thing 1 column but it seems to have worked. it's a big document with a lot of insertions. i need to go thru it all to see if it worked. thank you for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top