Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programatically changing value of checkbox in OO

Status
Not open for further replies.

sfetr

Programmer
Jun 9, 2006
5
PL
Hi,

I am trying to create Writer document (.sxw) based on DBF by Office Automation in VFP.

I have prepared function to change value of chceckbox in one of .prg files:

Code:

FUNCTION zmienBox(nazwa,wart)
form1 = this.doc.getDrawPage().forms().getByIndex(0)
nazwa= m.form1.getByName("nazwa")
nazwa.state = wart
ENDFUNC


where "nazwa" is the name of checkbox and "wart" is its value (0 or 1).

Then, I have prepared .dat File to manage checkbox value changing with following code:

Code:

zmienBox(rsa,1)


("rsa" is a name of one of checkboxes)

While processing ".odt" file I get message:
Variable 'RSA' is not found

Does anybody know how to make it work?

sfetr
 
I guess your code is OpenOffice automation code and not VFP? Perhaps you just need to pass RSA as a string?

I've nver used OpenOffice but I'd guess

zmienBox("rsa",1) && rsa is a string

and

nazwa= m.form1.getByName(nazwa) && nazwa is not a string

Brian
 
I tried to do, as you advised with changing rsa to string

(zmienBox("rsa",1) && rsa is a string)

and the result was, that I've achieved error: "File zmienbox.prg does not exist" (although I compile the VFP project with this function in one of .prg files).


I am sure, that code

form1 = this.doc.getDrawPage().forms().getByIndex(0)
nazwa= m.form1.getByName("nazwa")
nazwa.state = wart

inserted into .dat file returns correct result, but I can't do the same with about 70 checkboxes.

The problem begins, when I try to create function doing this (in .prg file).

sfetr
 
Hi,

Thanks, Brian - your advise almost working. :)

I've solved the problem. The function is:

Code:
function zmienbox(nazwa,wart)
 form1 = this.doc.getDrawPage().forms().getByIndex(0)
 nazwa= m.form1.getByName(m.nazwa)
 nazwa.state = wart 
endfunc

I've also changed the line in .dat file:
Code:
zmienbox("rsa",1)

Everything works fine now :)

sfetr
 
Glad it works.

I didn't realize OpenOffice had an object model. Certainly something to keep an eye on.

Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top