#1
|
|||
|
|||
Replacing horizontal lines
I've created some macros that will easily convert text that I've copied from my web browser and pasted into word into valid xhtml that I can then paste into Sigil and save as an epub. My issue is that sometimes the text pasted into Word has horizontal lines. How can I replace this lines with my usual code for dividers (an asterisk wrapped in paragraph tags)? |
#2
|
||||
|
||||
Hi eosrose,
That all depends on what kinds of horizontal lines you're dealing with; they could be underlines, paragraph borders or graphical objects, and each kind requires a differrent treatment.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Gee thanks Macropod. Your non-answer turns up at the top of google search, marked "solved".
Here's a sample, for inserted lines. Sub R___Lines_ReplaceAllWithString_wdInLineShapeHorizo ntalLine_ForEachLoop() ' deletes lines inserted by borders>horizontal line '1.===== Name pre-selected range (if LOOP is going to be executed or called on a TABLE) R___PRESELECTED_RANGE_SetAndRESELECTafterLOOPS Macro Dim PRESELECTED_RANGE As Range '1a.________ if no selection, msgbox select all, dont select or exit If Selection.Range = "" Then SELECT_RANGE = MsgBox("Select whole document?" & vbNewLine & _ "Cancel to make selection manually!" & vbNewLine & _ "No will run only on the selection type the cursor is in.", _ vbYesNoCancel + vbDefaultButton2) If SELECT_RANGE = vbYes Then Selection.WholeStory 'selects whole document - then save selection below ElseIf SELECT_RANGE = vbCancel Then Exit Sub End If 'SELECT_RANGE options (will continue with no selection made if yes or cancel not pressed) End If '1b.________ set preselected range Set PRESELECTED_RANGE = Selection.Range 'needs to be set after every preselected range dim, and after every loop '2.====== CODE range.[QUALIFIER] - loop actions on range here - eg: Dim INLINE_SHAPE As InlineShape For Each INLINE_SHAPE In PRESELECTED_RANGE.InlineShapes 'range MUST specify object types ' For Each INLINE_SHAPE In Selection.InlineShapes With INLINE_SHAPE If INLINE_SHAPE.Type = wdInlineShapeHorizontalLine Then INLINE_SHAPE.Select ' If MsgBox("Horiz line, replace?", vbYesNoCancel + vbDefaultButton2) = vbYes Then ' INLINE_SHAPE.Delete Selection.TypeText Text:="|L|" ' End If End If End With Next '3.====== reselect range for exit or next action (in MAIN macro, before LOOP macros called, +after each "next" command) '!!!!!!!!!!!! repeat in called macros PRESELECTED_RANGE.Select 'add after every "next" - for exit or next procedure End Sub |
Tags |
find/replace, horizontal lines, macros |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word replacing problem!!!! | Jamal NUMAN | Word | 2 | 07-08-2011 03:56 AM |
fine horizontal lines in photos | dkitain | Drawing and Graphics | 2 | 06-07-2011 09:49 AM |
Replacing default fonts | mark98101 | Word | 1 | 01-31-2011 02:31 PM |
Horizontal lines won't insert into full margins set in a doc. | rec | Outlook | 2 | 06-14-2010 09:47 AM |
Replacing / editting text | LisaC | Word | 0 | 02-25-2010 03:40 AM |