Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / August 2006

Tip: Looking for answers? Try searching our database.

how to use Word.SynonymInfo

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
moondaddy - 02 Aug 2006 08:27 GMT
I'm trying to get a list of string arrays from the SynonymInfo object and in
the reference documentation it gives this as an example:

       Dim synonymInfo1 As Microsoft.Office.Interop.Word.SynonymInfo
       Dim key As Object
       Dim returnValue As Object
       returnValue = synonymInfo1.SynonymList(key)

However, it doesnt show how to initialize 'key'.

so here's the code I came up with:

   Sub test3()
       Dim doc As Microsoft.Office.Interop.Word.Document = New
Microsoft.Office.Interop.Word.Document
       Dim myRange As Microsoft.Office.Interop.Word.Range
       myRange = doc.Words(1)

       myRange.Text = "Transmit"
       Dim synInfo As Microsoft.Office.Interop.Word.SynonymInfo
       synInfo = myRange.SynonymInfo

       Dim mCnt As Integer
       mCnt = synInfo.MeaningCount
       If mCnt > 0 Then

           Dim sCnt As Integer
           For sCnt = 1 To mCnt
               Dim i As Int16
               Dim synList As String()
               'the next line wont compile.  the compile error is listed
below.
               'synList = synInfo.SynonymList(sCnt)
               ''Error 1 Option Strict On disallows implicit conversions
from 'Object' to '1-dimensional array of String'. C:\Documents and
Settings\georgep\Local Settings\Application Data\Temporary
Projects\ConsoleApplication1\Module1.vb 34 27 ConsoleApplication1
               'I get the following exception on the next line
               'Unable to cast object of type 'System.String[*]' to type
'System.String[]'.
               synList = CType(CType(synInfo.SynonymList(sCnt), Array),
String())
               For i = 1 To CShort(UBound(CType(synList, Array)))
                   Console.WriteLine(synList(i))
               Next i
           Next sCnt
       End If
   End Sub

can someone please help me get started on this?

Signature

moondaddy@noemail.noemail

"Peter Huang" [MSFT] - 02 Aug 2006 11:53 GMT
Hi,

Currently I am researching the issue and we will reply here with more
information as soon as possible.
If you have any more concerns on it, please feel free to post here.

Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

moondaddy - 02 Aug 2006 20:41 GMT
Thanks I look forward to your reply.  I found very little code examples in
how to work with this in .net.  I found plenty in vba but that is of no use
in .net.  by the way, I'm working in vb.net 2.0.

Signature

moondaddy@noemail.noemail

> Hi,
>
[quoted text clipped - 12 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
"Peter Huang" [MSFT] - 03 Aug 2006 08:04 GMT
Hi,

Based on my test, this works at my side, you may have a try.

VB.NET 2005 Console App, Word 2003

Imports Word = Microsoft.Office.Interop.Word
Module Module1
   Sub Main()
       Dim wdApp As New Word.Application
       wdApp.Visible = True
       wdApp.Documents.Open("C:\test\test.doc")
       Dim SynInfo As Word.SynonymInfo
       SynInfo = wdApp.ActiveDocument.Content.Words(1).SynonymInfo
       Dim mCnt As Integer
       mCnt = SynInfo.MeaningCount
       MsgBox(mCnt)
       Dim Slist As Object = SynInfo.SynonymList(mCnt)
       For i As Integer = 1 To UBound(Slist)
           MsgBox(Slist(i))
       Next i
   End Sub
End Module

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
moondaddy - 04 Aug 2006 00:01 GMT
Thanks.  This doesnt compile.  I always use option strict.

Signature

moondaddy@noemail.noemail

> Hi,
>
[quoted text clipped - 31 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
"Peter Huang" [MSFT] - 04 Aug 2006 06:08 GMT
Hi,

Thanks for your response.
Due to the complex of Word Object Modal, it seems to be complex to write
the code with Option Strict On.

Anyway, here goes the code, you may have a try.

Option Strict On
Imports Word = Microsoft.Office.Interop.Word
Module Module1
   Sub Main()
       Dim wdApp As New Word.Application
       wdApp.Visible = True
       wdApp.Documents.Open("C:\test\test.doc")
       Dim SynInfo As Word.SynonymInfo
       SynInfo = wdApp.ActiveDocument.Content.Words(1).SynonymInfo
       Dim mCnt As Integer
       mCnt = SynInfo.MeaningCount
       MsgBox(mCnt)
       Dim Slist As Array = CType(SynInfo.SynonymList(mCnt), Array)
       For i As Integer = 1 To UBound(Slist)
           MsgBox(Slist.GetValue(i).ToString())
       Next i
   End Sub
End Module

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
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.