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 / February 2005

Tip: Looking for answers? Try searching our database.

help for extreme newbie

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kirk Soodhalter - 25 Feb 2005 18:26 GMT
Hi,

I have never worked with VB before and I am simply trying to automate
something I do many times in Word for work.  I recorded a macro and
found that I had to make some changes by hand.  Basically, the script
removes some formatting from selected text.  When I try to run it, it
chokes on the second line with an error reading "Compile Error: Object
Required".  Below is the code, could someone take a look and perhaps
explain the proper way to access text from the selection object.  MS
help was of no help in explaining this. Thanks so much!

Sub RemoveEndnoteFormatting()
'
' RemoveEndnoteFormatting Macro
'
'
    Dim strSelectText As String
    Set strSelectText = Selection.Text 'chokes here, highlights variable
    Selection.Cut
    Selection.TypeText Text:=" "
    Selection.PasteSpecial Link:=False, DataType:=wdPasteText,
Placement:= _
        wdInLine, DisplayAsIcon:=False
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = strSelectText
        .Replacement.Text = ""
        .Forward = False
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.Font.Superscript = wdToggle
End Sub
Jonathan West - 25 Feb 2005 18:47 GMT
Hi Kirk,

Remove the word "Set". You only use Set when you want to assign an object.
Strings dates and numbers are not objects.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

> Hi,
>
[quoted text clipped - 35 lines]
>     Selection.Font.Superscript = wdToggle
> End Sub
Kirk Soodhalter - 25 Feb 2005 23:14 GMT
Thanks, that worked perfectly.

-Kirk

> Hi Kirk,
>
> Remove the word "Set". You only use Set when you want to assign an
> object. Strings dates and numbers are not objects.
 
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.