Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

Macro to tab indent space indented HTML

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GoCoogs - 09 May 2006 19:15 GMT
I've worked for about an hour trying to figure out a way

<table>
<tr>
 <td>
   <table>

to be

<table>
    <tr>
        <td>
            <table>

I'm trying to format lots of source code.

Any ideas?
Doug Robbins - Word MVP - 09 May 2006 20:25 GMT
It's not really clear from your discription and example whether you want to
replace leading spaces with the same number of tab spaces or remove them,
but either way, you can do it by copying and pasting the code into a Word
document and then use Edit Replace, then copy and paste the code back into
the editor.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> I've worked for about an hour trying to figure out a way
>
[quoted text clipped - 13 lines]
>
> Any ideas?
GoCoogs - 10 May 2006 17:19 GMT
I am trying to replace the spaces with the same number of tabs. I tried
taking the code from Dreamweaver, putting it into WORD and writing a
macro but I had trouble.

I had trouble having the macro ignore ALL spaces within < > and only
replacing spaces immediately after a linebreak ^13 and before a < with
the same number of tabs.

> It's not really clear from your discription and example whether you want to
> replace leading spaces with the same number of tab spaces or remove them,
[quoted text clipped - 27 lines]
> >
> > Any ideas?
Russ - 10 May 2006 17:59 GMT
You can use find and replace to apply highlight or some other formatting to
'distinguish' parts of the document you want to ignore, like the "<*>" and
then attack the rest of the undistinguished parts of the document by telling
find and replace to only find, for instance, unhighlighted text patterns.
When you are done attacking, remove your highlighting or whatever special
formatting you used.

You don't have to try to cram it into just one find and replace pattern.

> I am trying to replace the spaces with the same number of tabs. I tried
> taking the code from Dreamweaver, putting it into WORD and writing a
[quoted text clipped - 35 lines]
>>>
>>> Any ideas?

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID <-- fix this before replying

Russ - 10 May 2006 18:48 GMT
> You can use find and replace to apply highlight or some other formatting to
> 'distinguish' parts of the document you want to ignore, like the "<*>" and

I should have used "\<*\>" as an example to escape the < >
characters and make them literal characters and not wildcards for
searching.

> then attack the rest of the undistinguished parts of the document by telling
> find and replace to only find, for instance, unhighlighted text patterns.
[quoted text clipped - 42 lines]
>>>>
>>>> Any ideas?

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID <-- fix this before replying

Doug Robbins - Word MVP - 10 May 2006 21:29 GMT
The following should do it:

Dim i As Long, j As Long, k As Long, tabstring As String
Dim apara As Paragraph
With ActiveDocument
   For k = 1 To .Paragraphs.Count
       tabstring = ""
       i = InStr(.Paragraphs(k), "<")
       If i > 1 Then
           For j = 2 To i
               tabstring = tabstring & vbTab
           Next j
           .Paragraphs(k).Range = tabstring & LTrim(.Paragraphs(k).Range)
       End If
   Next k
End With

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I am trying to replace the spaces with the same number of tabs. I tried
> taking the code from Dreamweaver, putting it into WORD and writing a
[quoted text clipped - 37 lines]
>> >
>> > Any ideas?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.