none
Visual Basic Express Edition 2008 references not working properly RRS feed

  • Question

  • Hi, I am new to Visual basic and am just trying to use Visual Basic Express Edition 2008 to write a small program that will open a microsoft word document (I am Using Word 2003) and then change some settings, and then change them back once the word document closes. I can get the document to open and found what I believe is the correct vba code but the Microsoft Word 11.0 Objet Library Reference doesn't seem to recognise it and nothing else I have seen online says that this shouldn't be working. This is what I have so far.

    Private

     

    Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

     

    On Error GoTo Err_Command1_Click

     

    Dim objword As Microsoft.Office.Interop.Word.Application

    objword =

    New Microsoft.Office.Interop.Word.Application

    objword.Visible =

    True

    objword.Documents.Open(

    "X:\French Intranet\French Intranet.doc", , , True)

    Microsoft.Office.Interop.Word.Application.Options.ShowWindowsInTaskbar =

    False

    Microsoft.Office.Interop.Word.Application.Options.CtrlClickHyperlinkToOpen =

    False

    But i get this error for the  _

    _"Microsoft.Office.Interop.Word.Application.Options.CtrlClickHyperlinkToOpen = False"

    And "Microsoft.Office.Interop.Word.Application.Options.ShowWindowsInTaskbar = False"

    but not for the objword

    Error 1 Reference to a non-shared member requires an object reference. C:\Documents and Settings\user\My Documents\Visual Studio 2008\Projects\StartForm2\StartForm2\Form1.vb 15 9 StartForm2

    I have added the microsoft word 11.0 object library but it doesn't seem to work for thsoe alst expressions.

    Any help much appreciated.

     

    • Moved by Kee Poppy Friday, December 17, 2010 3:33 AM (From:Visual Basic General)
    Wednesday, December 15, 2010 9:17 AM

Answers

  • I don't believe that Options is part of the reference:

    objWord.ShowWindowsInTaskbar = False
    
    ' and
    
    objWord.CtrlClickHyperlinkToOpen = False
    

    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Proposed as answer by Bessie Zhao Friday, December 17, 2010 8:11 AM
    • Marked as answer by Bruce Song Wednesday, December 22, 2010 11:19 AM
    Wednesday, December 15, 2010 8:36 PM

All replies

  • Hi,

    i don`t have word installed, but try this:

     

    ' remove this
    Microsoft.Office.Interop.Word.Application.Options.ShowWindowsInTaskbar = False
    
    Microsoft.Office.Interop.Word.Application.Options.CtrlClickHyperlinkToOpen = False
    
    ' add this
    objword.Options.ShowWindowsInTaskbar = False
    objword.Options.CtrlClickHyperlinkToOpen = False
    
    
    
    

    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    Wednesday, December 15, 2010 9:32 AM
  • I don't believe that Options is part of the reference:

    objWord.ShowWindowsInTaskbar = False
    
    ' and
    
    objWord.CtrlClickHyperlinkToOpen = False
    

    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Proposed as answer by Bessie Zhao Friday, December 17, 2010 8:11 AM
    • Marked as answer by Bruce Song Wednesday, December 22, 2010 11:19 AM
    Wednesday, December 15, 2010 8:36 PM
  • Hi Noneofyourbusinessreally,

    I am moving this thread to "Word for developer" forum for better support.

     

    Best Regards,

    Kee


    Kee Poppy [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 17, 2010 3:31 AM
  • Paul, Noneofyourbusinessreally,

    i have been checking word 11 object reference. There you can get a options object but you can`t set the ShowWindowsInTaskbar property. On the other hand you can`t set the CtrlClickHyperlinkToOpen property by using the application object but by using the options object.

    So the correct way by using word 11 object would be:

    objWord.ShowWindowsInTaskbar = False
    objWord.Options.CtrlClickHyperlinkToOpen = False


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    • Edited by Heslacher Monday, December 20, 2010 1:42 PM added bold text which i have missed
    Monday, December 20, 2010 6:47 AM
  • Hi Hannes,

    Yes, that is what I had found as well (see my post).


    Paul ~~~~ Microsoft MVP (Visual Basic)
    Monday, December 20, 2010 1:13 PM
  • Hi Paul,

    i have seen it, but i wanted to point out, that the CtrlClickHyperlinkToOpen property can`t be set by using the application object directly but by using the options property of the application object.

    I would have proposed your post as answer, but that has been allready done ;-)

    Edit: I just have seen, that i had missed the important part of my post. Just added in bold font.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    Monday, December 20, 2010 1:41 PM