Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-24-2012, 01:26 PM
sleake sleake is offline Code to Create & Format Document Sections Windows XP Code to Create & Format Document Sections Office 2007
Advanced Beginner
Code to Create & Format Document Sections
 
Join Date: Jul 2011
Posts: 60
sleake is on a distinguished road
Default Code to Create & Format Document Sections

I am working on a template for our project authors to enable them to “build” a document as they create it.

Background
I developed QAT with a number of building blocks to insert captions (for body and appendices), custom headers and footers for different orientations, custom tables, and tables of contents with and without appendices.

I added Word tools for insert section, orientation, page number format, linking/unlinking header/footer to previous, but using these tools may be too much for our novice authors. I tried using auto text to pre-format various sections, and recording a macro, and neither worked successfully.

The Question
I’d like to use a form that runs a VB procedure triggered by choices the authors make on the form. (I created the form in VB, but am not sure where to go from here.) Here’s the form structure.

Document Part (Body or Appendix)
Orientation (Portrait or Landscape)
Page Numbering (New Section or Continue from previous)

There are 8 possible choices:
Body-Portrait-New Section


Body-Portrait-Continue from previous
Body-Landscape-New Section
Body-Landscape- Continue from previous

Appendix-Portrait-New Section
Appendix -Portrait- Continue from previous
Appendix -Landscape-New Section
Appendix -Landscape- Continue from previous

I'm attaching a scheme I wrote for recording macros that will describe in more detail what I want to do. (I couldn't attach the template -- I see templates are not among the valid extensions.) I'd be grateful for any help you can provide or resources you can point me to.
Attached Files
File Type: doc Template Macro Schema (03-11-12).doc (38.5 KB, 13 views)
Reply With Quote
  #2  
Old 04-24-2012, 04:11 PM
macropod's Avatar
macropod macropod is offline Code to Create & Format Document Sections Windows 7 64bit Code to Create & Format Document Sections Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi sleake,

Since you're using Office 2007, why not simply define a series of custome Quick Parts for adding the various Sections. No vba or userforms required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-25-2012, 08:13 AM
sleake sleake is offline Code to Create & Format Document Sections Windows XP Code to Create & Format Document Sections Office 2007
Advanced Beginner
Code to Create & Format Document Sections
 
Join Date: Jul 2011
Posts: 60
sleake is on a distinguished road
Default Code to Create & Format Document Sections

I did try that. First, I created a series of section breaks with different headers/footers for portrait/landscape -- and defined the page numbering as I wanted, etc.

I copied only the one section break (and Heading 1 if it was to be a new section) and made that the autotext. The problem with that approach was that the page orientation and page numbers (start at 1 or continuous) didn't hold, and I had to use the Word orientation and format page numbering tools, which I had put on the QAT, to straighten them out -- and sometimes had to reinsert the headers and footers. With the tools, it was easy to do, but I wanted to make it easier for the authors.

Next I tried creating two section breaks and formatting the first one as I wanted. This worked better, as it retained the orientation, headers/footers and page numbering. But that extra page got confusing -- even to me who is designing it.

Do you have any suggestions as to how I should approach putting this together?
Reply With Quote
  #4  
Old 04-25-2012, 02:56 PM
macropod's Avatar
macropod macropod is offline Code to Create & Format Document Sections Windows 7 64bit Code to Create & Format Document Sections Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Sleake,

Your Quick Parts should only include the preceding Section break, not the one after. Clearly, if you're changing orientation, you cannot get away from having a page break before (which means the Section break will have to be of the 'next page' kind).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 04-25-2012, 04:56 PM
sleake sleake is offline Code to Create & Format Document Sections Windows XP Code to Create & Format Document Sections Office 2007
Advanced Beginner
Code to Create & Format Document Sections
 
Join Date: Jul 2011
Posts: 60
sleake is on a distinguished road
Default

All of my section breaks are Next Page, because we use chapter number with page numbers starting at 1. I recreated several single-section break section formatting buiding blocks today.

Our "big deal" challenge is inserting a landscape break (first page type) in the middle of a portrait section, and adjusting the headers/footers and page numbering to fit the inserted section. The next challenge is that most Appendix sections are landscape, which sometimes start with portrait, but usually follow a portrait section. Therefore, the headers/page numbering must change.

Using just the first section break does not retain the header/footer no link, or the orientation, or the page numbering (continue) properties. So it's pretty much useless to create a building block to do that. We may as well then teach authors how to insert a next page break, change orientation, insert headers and footers and reformat page numbers. This is what I'm trying to avoid, because the authors may be brilliant with web services, but have no proficiency or interest in Word.

We editors will spend most of our time reformatting the structure of the document headers, orientation and page numbering.

This is the reason I was thinking abut a form and code. Can you point me to a resource to learn how to do VBA in Word? I'm somewhat conversant in Access VBA, but Word confounds me. Everything is different. Or do you have other suggestions?
Reply With Quote
  #6  
Old 04-25-2012, 05:44 PM
macropod's Avatar
macropod macropod is offline Code to Create & Format Document Sections Windows 7 64bit Code to Create & Format Document Sections Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Using just the first section break does not retain the header/footer no link, or the orientation, or the page numbering (continue) properties.
That suggests you're doing something wrong. The default behaviour is to retain all of these.

A Word-oriented book that I did a technical review on, that you may find useful, is The Secret Life of Word, by Robert Delwood, published by XML Press (http://xmlpress.net)

Here's some basic code to add a landscape Section at the current insertion point:
Code:
Sub AddLandscapeSection()
Application.ScreenUpdating = False
Dim Sctn As Section, oHdFt As HeaderFooter
With Selection
  Set Sctn = .Sections.Add(Range:=.Range, Start:=wdSectionNewPage)
  With Sctn
    MsgBox .Range.Text
    With .PageSetup
      .PaperSize = wdPaperA4
      .Orientation = wdOrientLandscape
      .MirrorMargins = True
      .TopMargin = CentimetersToPoints(2.5)
      .BottomMargin = CentimetersToPoints(2.5)
      .LeftMargin = CentimetersToPoints(2.5)
      .RightMargin = CentimetersToPoints(2.5)
      .DifferentFirstPageHeaderFooter = True
    End With
    For Each oHdFt In .Headers
      oHdFt.LinkToPrevious = True
      'If oHdFt.LinkToPrevious = False Then oHdFt.Range.Text = "Some Text"
    Next
    For Each oHdFt In .Footers
      oHdFt.LinkToPrevious = True
      oHdFt.LinkToPrevious = True
      'If oHdFt.LinkToPrevious = False Then oHdFt.Range.Text = "Some Text"
    Next
  End With
  Set Sctn = Nothing
End With
Application.ScreenUpdating = True
End Sub
Whether you'll need all the parameters, or others I haven't indicated, depends on what your needs are.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 04-26-2012, 04:14 AM
sleake sleake is offline Code to Create & Format Document Sections Windows XP Code to Create & Format Document Sections Office 2007
Advanced Beginner
Code to Create & Format Document Sections
 
Join Date: Jul 2011
Posts: 60
sleake is on a distinguished road
Default

OK I'll recreate the landscape section and try again.

Thanks so much for recommending the book. I'll definitely get a copy,

Also thanks for the code, which I'll try out.

If I can get the autotext to work, that will be the easiest solution.
Reply With Quote
Reply

Tags
change orientation, change page numbering, templates



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change format of date when using Now function in VB code Bondai Excel Programming 2 03-02-2012 05:09 PM
Macro to export document sections to individual txt files? MJMR999 Excel Programming 0 02-18-2010 12:49 PM
Printing Sections of a Word Document Andy Jenkinson Word 4 02-12-2010 02:53 AM
Writing code with C# and VB.NET to create Outlook add-ins and other projects kistou Outlook 0 01-13-2010 04:23 AM
Document with selective sections printing krismason Word 0 07-09-2009 03:30 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft