Results 1 to 3 of 3

Thread: GetObject

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    79

    GetObject

    Help!!!!!!!

    Until Friday everything worked fine. Today, nothing seems to work.

    I'm using GetObject:

    VB Code:
    1. Dim objWordInstance As Word.Application
    2.  
    3.     objWordInstance = GetObject(, "Word.Application")

    Unfortunately after this objWordInstance is nothing even if I can see, that there is an instance of word. What might be wrong???

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    i put you a reply on dotnetforums.net , but here ya go.
    you could try looking for instances of the word process ( WINWORD ) , then dimming the word app as an object when using getobject , then casting it to what it should be. eg:
    VB Code:
    1. Dim wordApp As Word.ApplicationClass
    2.         Dim p As Process() = Process.GetProcessesByName("WINWORD")
    3.         If Not p.Length = 0 Then
    4.             Dim objWord As Object = GetObject(, "Word.Application")
    5.             wordApp = DirectCast(objWord, Word.ApplicationClass)
    6.             '/// word application found and can be manipulated now.
    7.         Else
    8.             '/// no word app found running.
    9.         End If
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    79
    Sorry, but I don't think, that there would be any difference.

    I changed nothing in my source code and since today, it doesn't work.

    Maybe, it would work if I declared my variable objWordinstance not as Word.Application but as Object but I really would like to know why it doesn't work any more.

    The way I'm trying it, I get an error
    "specified cast is not valid".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width