I'm trying to put something into the windows clipboard from IP:
Devised following test-code:
Sub XDocument_OnLoad(eventObj)
Dim oTekst: Set oTekst =
XDocument.DOM.selectSingleNode("//my:myFields/my:txbCP")
on error resume next
oTekst.Text = "Hello, this was entered in this box at form - load :
" & Right(Now(), 8)
XDocument.View.selecttext(oTekst.missing.value)
XDocument.View.ExecuteAction ("copy") ' Programmatically put in
clipboard.
if err.number <> 0 then
msgbox err.Description
err.Clear
end if
Set oTekst = Nothing
End Sub
I get an error in the ... XDocument.View.selecttext(oTekst) line
- also tried to insert "missing.value" to no avail?
Errormessage: an object is obligatory (translated from Danish, maybe
another error in English). I've transcripted from JS that I don't know
very wll, but it looks ok to me though?
What am I doing wrong?
S.Y.M. Wong-A-Ton - 16 Dec 2006 01:56 GMT
> Errormessage: an object is obligatory (translated from Danish, maybe
> another error in English).
Nice translation from Danish! It was close enough. :)
If you are getting the error message "Object is required" it means that
oTekst is Nothing. You can test this with the following line of code:
XDocument.UI.Alert(oTekst Is Nothing)
If oTekst is Nothing, you need to revise the XPath to the node. Try
something like "//my:txbCP" or "/my:myFields/my:txbCP" instead of
"//my:myFields/my:txbCP".
I tried out your code and made a few corrections. This is what I got to work:
Dim oTekst
Set oTekst = XDocument.DOM.selectSingleNode("//my:field1")
on error resume next
oTekst.text = "Hello, this was entered in this box at form - load :" &
Right(Now(), 8)
XDocument.View.SelectText(oTekst)
XDocument.View.ExecuteAction("Copy")
if err.number <> 0 then
msgbox err.Description
err.Clear
end if
Set oTekst = Nothing
---
S.Y.M. Wong-A-Ton
> I'm trying to put something into the windows clipboard from IP:
>
[quoted text clipped - 29 lines]
>
> What am I doing wrong?
sam_puploh - 17 Dec 2006 16:47 GMT
Hello S. Y. M. Wong-A-Ton
Thanks for your help - I will try it tomorrow at work. Strange though
about that object! The assignment of the text to the object works
without problems, so the object seems to point to the right control?
Anyhow, perhaps the view property needs another xpath as you suggest.
I'll dig into it tomorrow - thanks again
Regards Sam
sam_puploh skrev:
> I'm trying to put something into the windows clipboard from IP:
>
[quoted text clipped - 29 lines]
>
> What am I doing wrong?
sam_puploh - 17 Dec 2006 18:12 GMT
Hello again,
had the opportunity to try it at home...
Made a completely new IP-form. Chose the on-open event from the
programming menu.
copied your code into it, and I still get same error.
The oTekst object IS something! - because ... a msgbox oTekst is
nothing ...tells me "FALSE".
So this is a real mystery for me.
What is going on?
Reg.
Sam
sam_puploh skrev:
> I'm trying to put something into the windows clipboard from IP:
>
[quoted text clipped - 29 lines]
>
> What am I doing wrong?
S.Y.M. Wong-A-Ton - 17 Dec 2006 19:11 GMT
I'm not sure why it doesn't work for you. What version of InfoPath do you
have installed? 2003 with SP2?
---
S.Y.M. Wong-A-Ton
> Hello again,
>
[quoted text clipped - 49 lines]
> >
> > What am I doing wrong?
S.Y.M. Wong-A-Ton - 17 Dec 2006 19:51 GMT
Also, try putting the code in the event handler for a button or somthing
else, rather than the OnLoad event for the form, since the View might not be
fully loaded in the OnLoad event.
---
S.Y.M. Wong-A-Ton
> Hello again,
>
[quoted text clipped - 49 lines]
> >
> > What am I doing wrong?
sam_puploh - 17 Dec 2006 20:53 GMT
Even more strange! I put the code into a cmd_buttonclick event.
New error:
(Again translated from Danish: ...The chosen bstrAction-value for the
call to View.ExecuteAction can not be used with the actual
selection...)
If I remove the ExcecuteAction line I get this error:
... The specified pxnField-value for the call to View.SelectText is not
valid ...
BTW IP 2003 SP2! (But Danish version, which is known for several
translation related bugs!)
I'm really baffled about these error especially because it seems to
work in your IP?
Can you give me another hint?
S.Y.M. Wong-A-Ton skrev:
> Also, try putting the code in the event handler for a button or somthing
> else, rather than the OnLoad event for the form, since the View might not be
[quoted text clipped - 55 lines]
> > >
> > > What am I doing wrong?
sam_puploh - 17 Dec 2006 21:08 GMT
Forget about latest post - It was due to a mismatch for the
node-element (Used your english Field instead of Felt.
When this was corrected I'm back to my missing object problem which
started this dialog :(
sam_puploh skrev:
> Even more strange! I put the code into a cmd_buttonclick event.
>
[quoted text clipped - 77 lines]
> > > >
> > > > What am I doing wrong?
sam_puploh - 17 Dec 2006 22:06 GMT
Problem solved - at last.
IP didn't like the assignment to the node object in same procedure.
When I moved the SelectText to another function (and corrected my xpath
to two back-slaches it worked.
Thanks for the inspiration - hope someone can use this for the same
purpose!
sam_puploh skrev:
> Forget about latest post - It was due to a mismatch for the
> node-element (Used your english Field instead of Felt.
[quoted text clipped - 84 lines]
> > > > >
> > > > > What am I doing wrong?
S.Y.M. Wong-A-Ton - 17 Dec 2006 23:52 GMT
No worries. Glad you finally got it solved!
---
S.Y.M. Wong-A-Ton
> Problem solved - at last.
>
[quoted text clipped - 94 lines]
> > > > > >
> > > > > > What am I doing wrong?