![]() |
#1
|
|||
|
|||
![]()
hello,
I am trying have text that comes from a macro field automatically aligned in the document. After the text is added to the document, the second line of the text starts on a new line, I need the second line indented like the first line. How can I do this? See attachment. thanks |
#2
|
||||
|
||||
![]()
Your code that inserts the content of the 'enclosures' box needs to use something like:
.Text = Replace(Enclosures.Text, vbcr, ", ")
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Does this look coorect?
Code:
Private Sub txtEnclosureAttached_Change() Dim Rng As Range Set Rng = ActiveDocument.Bookmarks(""bmkEnclosureAttached"").Range With Rng .Text = Replace(Enclosures.Text, vbcr, ", ") Application.ScreenRefresh End With ActiveDocument.Bookmarks.Add ""bmkEnclosureAttached"", Rng End Sub Last edited by macropod; 03-13-2012 at 04:57 PM. Reason: Added code tags |
#4
|
||||
|
||||
![]()
No. Instead of (""bmkEnclosureAttached"") you should have (bmkEnclosureAttached). I'd also question why you're using a Change event instead of the Update event. The change event is really only useful if you want edits on the userform to be reflected in the document as they're being typed, rather than once the typing's been completed and you exit the textbox.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
I am still learning the VB language. I am more of a designer than programmer... How does this look:
Code:
Private Sub txtEnclosureAttached_Update() Dim Rng As Range Set Rng = ActiveDocument.Bookmarks(bmkEnclosureAttached).Range With Rng .Text = Replace(Enclosures.Text, vbCr, ", ") Application.ScreenRefresh End With ActiveDocument.Bookmarks.Add bmkEnclosureAttached, Rng End Sub Last edited by macropod; 03-13-2012 at 04:58 PM. Reason: Added code tags |
#6
|
||||
|
||||
![]()
Yes, that looks OK, though you don't need the With .. End With structure given you're only doing one thing with the range:
Code:
Private Sub txtEnclosureAttached_Update() Dim Rng As Range Set Rng = ActiveDocument.Bookmarks(bmkEnclosureAttached).Range Rng.Text = Replace(Enclosures.Text, vbCr, ", ") Application.ScreenRefresh ActiveDocument.Bookmarks.Add bmkEnclosureAttached, Rng End Sub PS: Please use code tags when posting code - you can find them on the Advanced tab.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
![]()
Everytime I try to edit the EnclosureAttached field, it comes up blank.. what am I doing wrong here:
see attached |
#8
|
||||
|
||||
![]()
Sorry, you need to use:
Rng.Text = Replace(txtEnclosureAttached.Text, vbCr, ", ")
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
![]()
This is the code I have. I have a Update and a Change event. Should I remove the change event?
and what does vbCr, ", " mean? Code:
Private Sub txtEnclosureAttached_Update() Dim Rng As Range Set Rng = ActiveDocument.Bookmarks(bmkEnclosureAttached).Range Rng.Text = Replace(txtEnclosureAttached.Text, vbCr, ", ") Application.ScreenRefresh ActiveDocument.Bookmarks.Add "bmkEnclosureAttached", Rng End Sub Private Sub txtEnclosureAttached_Change() Dim Rng As Range Set Rng = ActiveDocument.Bookmarks("bmkEnclosureAttached").Range Rng.Text = Replace(txtEnclosureAttached.Text, vbCr, ", ") Application.ScreenRefresh ActiveDocument.Bookmarks.Add "bmkEnclosureAttached", Rng End Sub |
#10
|
||||
|
||||
![]() Quote:
Quote:
Replace(txtEnclosureAttached.Text, vbCr, ", ") which basically says to replace any carriage returns in the 'txtEnclosureAttached.Text' with a comma followed by a space.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Bug in PPT 2007 - Font and line spacing in text boxes | Amateur | PowerPoint | 0 | 09-01-2010 03:34 AM |
How do I import text columns with specified spacing between words w/o losing format? | Fucius | Word | 0 | 08-09-2010 06:23 PM |
![]() |
marshalx | Word | 2 | 10-28-2009 02:37 AM |
Print spacing in Word document | veekay99 | Word | 16 | 04-21-2009 01:18 AM |
How to link text from one document to another | nospamforyou | Word | 0 | 10-09-2008 09:14 AM |