Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-23-2012, 05:14 AM
rufusfrog rufusfrog is offline indent alternate lines by different amounts Windows 7 64bit indent alternate lines by different amounts Office 2003
Novice
indent alternate lines by different amounts
 
Join Date: Feb 2012
Posts: 3
rufusfrog is on a distinguished road
Default indent alternate lines by different amounts

I need to write a macro in Word 2003 to format poetry to indent the even lines more than the odd. I can write the logic but don't know enough VBA to write the code. I think to make the code work I'll need each line as a separate paragraph which I can just use find/replace to achieve so assume that's done.



The logic, I think, is:
Within the selection,
...indent the first paragraph 1",
...indent the next paragraph 1.25",
repeat these two actions until end of selection.

Can anyone help me with the code to achieve this?
Reply With Quote
  #2  
Old 02-24-2012, 09:29 PM
macropod's Avatar
macropod macropod is offline indent alternate lines by different amounts Windows 7 64bit indent alternate lines by different amounts Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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 rufusfrog,

I think it's time to learn how to use Word's paragraph Styles. With them, you can define how much indent different paragraphs should have and you probably won't need a macro.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 02-25-2012, 02:29 AM
rufusfrog rufusfrog is offline indent alternate lines by different amounts Windows 7 64bit indent alternate lines by different amounts Office 2003
Novice
indent alternate lines by different amounts
 
Join Date: Feb 2012
Posts: 3
rufusfrog is on a distinguished road
Default

I don't find that helpful - either I haven't explained myself well or there is something about styles I do not know - is there a way of creating a style that treats alternate lines differently, and if so how?

I'm aware how to define styles and apply them manually. What I have here are poems of many hundreds of lines - maybe over a thousand in some cases (e.g. Dante's divine comedy - over 400 pages) it's not hard to select each verse or canto and apply the first style - but then to go through, selecting every alternate line and apply the second style - that is the work of many, many hours. Surely it is the role of macros to automate the tedious and repetitive?
Reply With Quote
  #4  
Old 02-25-2012, 02:53 AM
macropod's Avatar
macropod macropod is offline indent alternate lines by different amounts Windows 7 64bit indent alternate lines by different amounts Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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 rufusfrog,

If you format your poems so that each line is a separate Word paragraph, each line can have a separate paragraph Style applied.

Alternatively, you can use paragraph breaks after every second line and use a single Style, with a 1.25in indent and a -.25in hanging indent, you can use a single paragraph Style.

The only way to do this within a single paragraph is to apply a 1in indent to the whole paragraph, then apply a 0.25in tab to each alternate line. That's because, other than having a different first line indent, you can't change the indent levels for different lines within a paragraph, with or without a macro.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 02-25-2012, 03:03 AM
rufusfrog rufusfrog is offline indent alternate lines by different amounts Windows 7 64bit indent alternate lines by different amounts Office 2003
Novice
indent alternate lines by different amounts
 
Join Date: Feb 2012
Posts: 3
rufusfrog is on a distinguished road
Default

This I already know. What I don't know is how to speedily arrange hundreds of lines this way. Even to go through and change every other end-of-line from ^l to ^p over hundreds of pages would be extremely tedious and time-consuming (and doesn't help with poems that come in groups of three lines, each with a different indent or other, more complex, patterns). Which is why I want help writing a macro as described - once I have the simple case - every other line - I'll be able to modify it myself for the more complicated cases.
Reply With Quote
  #6  
Old 02-25-2012, 03:36 AM
macropod's Avatar
macropod macropod is offline indent alternate lines by different amounts Windows 7 64bit indent alternate lines by different amounts Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

As yet, you haven't said whether your poem paragraphs are formatted with a separate paragraph break per line, or just a manual line break.

Assuming your document is formatted with manual line breaks within stanzas and paragraph breaks between them, the following will work:
First, ensure there are two paragraph breaks between stanzas. If there is presently only one, you can use a standard Find/Replace, where:
Find = ^p
Replace = ^p^p
and, for the Find Style, choose the paragraph Style you've applied to the stanzas.
Second use a wildcard Find/Replace, where:
Find = ([!^11^13]{1,}[^11^13])([!^13][!^11^13]{1,}[^11^13])
Replace = \1^t\2
Third, format the Style in which the stanzas are typed with a 1in indent and a tab stop at 1.25in
Fourth, delete the double paragraph breaks if you don't want them, using a standard Find/Replace, where:
Find = ^p^p
Replace = ^p
and, for the Find Style, choose the paragraph Style you've applied to the stanzas.

If you really want a macro for this, simply activate the macro recorder immediately before starting and end it immediately after you've finished.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
mail merge with duplicate names but different dollar amounts bh24524 Mail Merge 27 03-24-2014 01:15 PM
indent alternate lines by different amounts Getting blank lines instead of supressed lines. Welshie82 Mail Merge 2 11-14-2011 01:41 AM
can't space/indent lines, stuck joelron26 Word 3 10-07-2010 08:56 AM
Automatic insertion of blank pages or alternate text Diopippo Word 0 07-06-2010 12:13 AM
Alternate headings and footers Dr Aryn, DC Word 0 07-10-2009 05:44 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:28 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