Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #46  
Old 02-05-2012, 04:33 AM
Jana Jana is offline Please help copy inside brackets Windows 7 32bit Please help copy inside brackets Office 2007
Novice
Please help copy inside brackets
 
Join Date: Dec 2011
Posts: 28
Jana is on a distinguished road
Default Hi Paul,


I'm interesting only for the full stops. Some headings ends with fullstops some of them not. For example, if Heading 1 and 3 ends with full stop but not the heading 2, the result must be {Heading 1., Heading 2, Heading 3..}. I'm not interesting for other abbreviations or spaces in this part for sure. So what i need is to change this to {Heading 1, Heading 2, Heading 3.}. The perfect approach would be, the macro check if heading has full stop and delete it before put them inside brackets, if not then check for the next heading and so on.
Reply With Quote
  #47  
Old 02-05-2012, 04:45 AM
macropod's Avatar
macropod macropod is offline Please help copy inside brackets Windows 7 64bit Please help copy inside brackets Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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 Jana,

Replace:
Code:
                'StrTxt = StrTxt & Left(oPara.Range.Text, Len(oPara.Range.Text) - 1) & ", "
with:
Code:
                StrTxt = StrTxt & Left(oPara.Range.Text, Len(oPara.Range.Text) - 1)
                While Right(StrTxt, 1) = "."
                  StrTxt = Left(StrTxt, Len(StrTxt) - 1)
                Wend
                StrTxt = StrTxt & ", "
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #48  
Old 02-05-2012, 05:44 AM
Jana Jana is offline Please help copy inside brackets Windows 7 32bit Please help copy inside brackets Office 2007
Novice
Please help copy inside brackets
 
Join Date: Dec 2011
Posts: 28
Jana is on a distinguished road
Default Working but with a little problem

Hi Paul,

This is what i wanted to do, but the problem is that the code also deletes the last full stop after the last heading. I need to add the headings inside brackets divided by comma or else and at the end put a full stop. Let me show you what i mean.
i.e {Heading 1, Heading 2, Heading 3.}.
The fixed code working fine but also deletes the last full stop which i dont want to. i.e {Heading 1, Heading 2, Heading 3}. I dont know if this makes things complicated. (This is my fault, because the code from the beginning produce this string {Heading 1, Heading 2, Heading 3}).
Reply With Quote
  #49  
Old 02-05-2012, 01:42 PM
macropod's Avatar
macropod macropod is offline Please help copy inside brackets Windows 7 64bit Please help copy inside brackets Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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 Jana,

There is no practical way for the code to 'know' whether there are any more headings to include at the time it is adding each one. The only practical way of adding in a stop is to do so after all of the headings have been added to StrTxt and before they are written into the document. To do that, you could change:
StrTxt = "{" & Left(StrTxt, Len(StrTxt) - 2) & "}"
to:
StrTxt = "{" & Left(StrTxt, Len(StrTxt) - 2) & ".}"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #50  
Old 02-05-2012, 02:41 PM
Jana Jana is offline Please help copy inside brackets Windows 7 32bit Please help copy inside brackets Office 2007
Novice
Please help copy inside brackets
 
Join Date: Dec 2011
Posts: 28
Jana is on a distinguished road
Default Working as expected!!!

Paul, i think that i am ok, Thanks again for your help and your time. All working fine.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gray square brackets waldux Word 8 09-25-2013 04:14 PM
Please help copy inside brackets Find/Replace Brackets Problem fatso Word 2 08-04-2011 11:34 AM
brackets citation uncung Word 1 07-13-2011 01:39 PM
Brackets Issue... DarkJudge1 Outlook 0 07-06-2010 05:15 PM
copy a file which does not have copy option jkind Word 0 01-17-2010 09:25 AM

Other Forums: Access Forums

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