Solved: Can someone help me with a macro?

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

rameam

Thread Starter
Joined
Mar 14, 2003
Messages
435
I have a doc with superscript numbers immediately following a word (no space). What I need to do is put a space between the last letter in the word and the first superscripted number. I can put 'any letter, any digit' in the find box, and it will find them, but I don't know how to go from there to add the space. :confused:

This would save me a great deal of time, as I am doing them one at a time at present. Any help would be greatly appreciated!

I'm using Word 97. :)
 
Joined
Dec 9, 2003
Messages
563
Hi Rameam,

I'm just wondering what your superscript numbers actually are?
Are they refering to Footnotes or Endnotes ? if so then insert them as such and the formatting will be automatic.

I can't remenber Word 97, on later versions its from the Toolbar menu, Insert, Reference, Footnote (then select Footnote or Endnote).

Hope this is of use

lol
Hew
 

rameam

Thread Starter
Joined
Mar 14, 2003
Messages
435
Thanks for your response, Hemanm.

The numbers are not footnotes or endnotes. They must stay where they are.

The macro I need may not be possible in Word, but I sure hope it is.

Anyone else have any ideas?
 

rameam

Thread Starter
Joined
Mar 14, 2003
Messages
435
This is a tiny mockup of what I'm working with. It should be enough to give you a better idea of what I need - a space between last letter and first #.

Thanks for your help.
 

Attachments

Joined
Sep 4, 2003
Messages
4,916
This should take care of you.

Code:
Public Sub InsertSpace()

Selection.HomeKey Unit:=wdStory

Do Until ActiveDocument.Bookmarks("\Sel") = _
   ActiveDocument.Bookmarks("\EndOfDoc")

Selection.Find.ClearFormatting
Selection.Find.Text = "^#"
Selection.Find.Execute

If Selection.Font.Superscript = True Then
Selection.InsertBefore Chr(32)
Selection.MoveRight Unit:=wdWord, Count:=1
End If

Loop
End Sub
Rollin
 

rameam

Thread Starter
Joined
Mar 14, 2003
Messages
435
Rollin Again,

It works great, except for one problem. I almost always have a number at the end of a paragraph with nothing but a paragraph mark after it. When it gets there it just continues spacing. I didn't know how to stop it except using the CAD function. I thought it would stop by pressing Esc, but it didn't. I didn't think about that happening when I made the mockup. Sorry!

What do I add to the macro to stop that?

You don't know how much I appreciate your help.
 

rameam

Thread Starter
Joined
Mar 14, 2003
Messages
435
Rollin Again,

After trying it a few more times, I find that when it comes to the end of the doc, it just keeps either spacing or the hour glass stays on and keeps jittering.

Thought the added info might help.
 
Joined
Sep 4, 2003
Messages
4,916
You can press CTRL + BREAK and select end as a temporary way to halt the code execution. I'll play around with the code a bit to see if I can find how to overcome this problem.

Rollin
 
Joined
Sep 4, 2003
Messages
4,916
Here you go. This should take care of the Endless Loop
Code:
Public Sub InsertSpace()

Selection.HomeKey Unit:=wdStory

Do Until ActiveDocument.Bookmarks("\Sel") = _
ActiveDocument.Bookmarks("\EndOfDoc")

Selection.Find.ClearFormatting
Selection.Find.Text = "^#"
Selection.Find.Wrap = wdFindStop

If Selection.Find.Execute = True Then
If Selection.Font.Superscript = True Then
Selection.InsertBefore Chr(32)
Selection.MoveRight Unit:=wdWord, Count:=1
End If
Else
End
End If

Loop
End Sub
Rollin
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top