Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: 12 Oct 2005 14:56:31 -0700,    group: microsoft.public.word.word97vba        back       


Case with field as text   
when the first word of the selection is a field (in this case a
macrobutton) how to I test for that in my case statement

    'sets the range and text to the first word of the selection if it
is not a [
    strTest = Selection.Words(1)

    Select Case Selection.Words(1)
        Case "["
            Set rgeFirstWordInSentence = Selection.Words(2)
        Case "{["
            Dim Answer As Long
                Answer = MsgBox("Is this action for the Brace ""{"" ?",
vbYesNo, "Brace or Bracket")
                Select Case Answer
                Case vbYes
                    Set rgeFirstWordInSentence = Selection.Words(2)
                Case vbNo
                    Set rgeFirstWordInSentence = Selection.Words(3)
                End Select
        Case "{"
            Set rgeFirstWordInSentence = Selection.Words(2)
        Case strTest
            Set rgeFirstWordInSentence = Selection.Words(2)
        Case Else
            Set rgeFirstWordInSentence = Selection.Words(1)
    End Select
date: 12 Oct 2005 14:56:31 -0700   author:   frogman

Re: Case with field as text   
I used the code to copy the variable to the clipboard and pasted it
into my case

Public Sub CopyToClipBoard()

    'This is how to clear the clipboard
    Dim MyData As DataObject

    Set MyData = New DataObject
    MyData.SetText ""
    MyData.PutInClipboard


    'This is how to get the text from a string variable into the
clipboard:

    Dim MyData As DataObject
    Dim strClip As String
    strClip = "Hi there"

    Set MyData = New DataObject

    MyData.SetText strClip
    MyData.PutInClipboard

    'This is how to get the text on the clipboard into a string
variable:

    Dim MyData As DataObject
    Dim strClip As String

    Set MyData = New DataObject
    MyData.GetFromClipboard
    strClip = MyData.GetText

End Sub


And this is the result

    Select Case Selection.Words(1)
        Case "["
            Set rgeFirstWordInSentence = Selection.Words(2)
        Case "{["
            Dim Answer As Long
                Answer = MsgBox("Is this action for the Brace ""{"" ?",
vbYesNo, "Brace or Bracket")
                Select Case Answer
                Case vbYes
                    Set rgeFirstWordInSentence = Selection.Words(2)
                Case vbNo
                    Set rgeFirstWordInSentence = Selection.Words(3)
                End Select
        Case "{"
            Set rgeFirstWordInSentence = Selection.Words(2)
        Case " "
            blnIsField = True
            Set rgeFirstWordInSentence = Selection.Words(2)
        Case "[,"
            Set rgeFirstWordInSentence = Selection.Words(2)
        Case Else
            Set rgeFirstWordInSentence = Selection.Words(1)
    End Select

if there is a way to type this in that would be helpful too
date: 13 Oct 2005 07:28:33 -0700   author:   frogman

Re: Case with field as text   
Hi frogman,

If all you need to do is find out what fields are within the selected range,
you could use something like:

Sub List_Fields()
With Selection.Range
    For i = 1 To .Fields.Count
        MsgBox "Field " & i & ", Type: " & .Fields(i).Type _
        & vbCrLf & "Code: " & .Fields(i).Code
    Next
End With
End Sub

Cheers


"frogman"  wrote in message
news:1129154191.527942.208820@g14g2000cwa.googlegroups.com...
> when the first word of the selection is a field (in this case a
> macrobutton) how to I test for that in my case statement
>
>     'sets the range and text to the first word of the selection if it
> is not a [
>     strTest = Selection.Words(1)
>
>     Select Case Selection.Words(1)
>         Case "["
>             Set rgeFirstWordInSentence = Selection.Words(2)
>         Case "{["
>             Dim Answer As Long
>                 Answer = MsgBox("Is this action for the Brace ""{"" ?",
> vbYesNo, "Brace or Bracket")
>                 Select Case Answer
>                 Case vbYes
>                     Set rgeFirstWordInSentence = Selection.Words(2)
>                 Case vbNo
>                     Set rgeFirstWordInSentence = Selection.Words(3)
>                 End Select
>         Case "{"
>             Set rgeFirstWordInSentence = Selection.Words(2)
>         Case strTest
>             Set rgeFirstWordInSentence = Selection.Words(2)
>         Case Else
>             Set rgeFirstWordInSentence = Selection.Words(1)
>     End Select
>
date: Fri, 14 Oct 2005 17:32:26 +1000   author:   macropod lid

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us