1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Can someone help me with a macro?

Discussion in 'Business Applications' started by rameam, Jan 27, 2005.

Thread Status:
Not open for further replies.
Advertisement
  1. rameam

    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. :)
     
  2. Yorkshire Guy

    Yorkshire Guy

    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
     
  3. rameam

    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?
     
  4. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    Post a sample word document and I'll see if I can write the macro for you.

    Rollin
     
  5. rameam

    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.
     

    Attached Files:

  6. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    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
     
  7. rameam

    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.
     
  8. rameam

    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.
     
  9. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    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
     
  10. rameam

    rameam Thread Starter

    Joined:
    Mar 14, 2003
    Messages:
    435
    Thank you.
     
  11. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    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
     
  12. rameam

    rameam Thread Starter

    Joined:
    Mar 14, 2003
    Messages:
    435
    Fantastic!!!

    Thank you so very much!
     
  13. Sponsor

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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/324170

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice