Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-23-2011, 05:05 PM
lkatz1 lkatz1 is offline Insert Tabs Between words Windows XP Insert Tabs Between words Office 2010 32bit
Novice
Insert Tabs Between words
 
Join Date: Nov 2011
Posts: 4
lkatz1 is on a distinguished road
Default Insert Tabs Between words

How can we do a replace by format when we want to find a space between words in Microsoft Word that the first word has a different font then the second?
Example: word1 Word2
we want to put a tab in the space between the 2 words
We have the following macro but only works on first line

Sub ScratchMacro()
Dim oWord As Range
Dim oRgn As Range
For Each oWord In ActiveDocument.Range.Words
If oWord.Font.Name = "Tahoma" Then
If oWord <> vbTab Then
On Error GoTo Err_Handler
If oWord.Words.Last.Next.Font.Name = "Times New Roman" Then


oWord = Replace(oWord, " ", vbTab)
End If
End If
End If
Next oWord
lbl_Exit:
Exit Sub
Err_Handler:
Resume lbl_Exit
End Sub
Reply With Quote
  #2  
Old 11-30-2011, 05:23 AM
macropod's Avatar
macropod macropod is offline Insert Tabs Between words Windows 7 64bit Insert Tabs Between words 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 lkatz1,

If you don't care what the following font is, you can do this without a macro, using an ordinary Find/Replace procedure, where:
Find = no text specified, but just the font of interest
Replace = ^&^t
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Tabs Between words Removing tabs Taylor Word 10 11-28-2011 03:38 PM
Insert Tabs Between words Outlook Calendar tabs in 2011 solomani Outlook 2 07-15-2011 08:30 PM
Why Words doesn’t show the style of the selected words automatically???? Jamal NUMAN Word 0 04-14-2011 03:20 PM
Insert Tabs Between words Help with tabs kapnasty Word 9 01-24-2011 01:25 PM
Adjusting Tabs erselking Word 1 10-23-2008 02:57 PM

Other Forums: Access Forums

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