2

I keep getting an error while running this script:

Sub sendtext()

    Dim msgr as instantmessengerconversationWndAdvanced
    Dim Text as string

    Text= range("a1").value

    Instantmessage (person@mail.com)
    msgr.sendtext(Text)

End Sub

It opens the chat window with the correct person listed, but I get an error when it gets to the text part:

Run-Time error '494': Object Required

I checked the references and browsed the object library. I do see the sendtext() function listed and this has me confused. Am I missing something?Any help is appreciated.

Teamothy
  • 2,000
  • 3
  • 16
  • 26
MC3000
  • 21
  • 3
  • 1
    What instant messenger program/library is this? Ideally this should be tagged with the name of the program and answered with how to actually get the object. – Random832 Mar 25 '15 at 17:13
  • I'm trying to use Cisco Jabber messenger. I am referencing the CUCMESSENGER 1.0 Type Library where it lists the function available. – MC3000 Mar 25 '15 at 17:33

1 Answers1

3

You are not actually creating an instance of the instantmessengerconversationWndAdvanced class, just a variable (which is initialized to Nothing).

Check the documentation of the object library you are using for how to obtain an instance of the class.

Random832
  • 37,415
  • 3
  • 44
  • 63
  • 1
    I'm out of votes for the day (otherwise I'd +1 this), but that seems like the logical answer. – LittleBobbyTables - Au Revoir Mar 25 '15 at 17:14
  • Yup, 30 as you see fit + 10 more for questions. – LittleBobbyTables - Au Revoir Mar 25 '15 at 17:15
  • In VBA the declared variable is not 'initalized' to 'None' but rather to 'Nothing'. To obtain instance is achieved with keywords Set and New, example: ```Set msgr = New instantmessenger``` – Daniel Dušek Mar 25 '15 at 18:37
  • @dee sorry, I knew it was Nothing, but I forgot for some reason when answering this – Random832 Mar 25 '15 at 18:42
  • Where can I find the documentation for the object library? I tried changing it to: set msgr= instant message (person@mail.com) and it still opens jabber window with the correct person then gives me an error. – MC3000 Mar 25 '15 at 19:52
  • @MC3000 is it the same error? What is your actual code? "`set msgr= instant message (person@mail.com)`" is not valid syntax. – Random832 Mar 26 '15 at 13:00
  • @Random832 I am using "set msgr = Messenger.InstantMessege(person@email.con). It will still open a jabber chat window with the correct individual listed, but now I get "Run-time error 91: Object variable or With block variable not set". I had this working with ms communicator but can't get it to work with Jabber. Any ideas? – MC3000 Mar 26 '15 at 15:15
  • That is not valid syntax, and it's also spelled wrong. Please paste your actual code instead of retyping it. Please paste the entire function of your code into the code block in your question. If it contains private information, change the code to a generic example and make sure the changed code still works before pasting it. – Random832 Mar 26 '15 at 15:16
  • Also is there any documentation on this library available from the manufacturer of the IM program? Not having this information makes it very difficult to help you. – Random832 Mar 26 '15 at 15:18
  • I have looked for it on Ciscos website and on the folder where the dll file is located. Let me switch from my mobile to a pc to copy and paste the code. – MC3000 Mar 26 '15 at 15:26