Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Checkboxes in MS Word via ASP


Message #1 by "John Mountain" <johnm@a...> on Sat, 9 Mar 2002 19:15:55
I have written an ASP page that opens an instance of Word on the server. 

It then opens a document on the server. Inside the document there are a 

series of Strings that need replacing with checkboxes. I have managed to 

get the application to insert a checkbox instead of the bookmark but I 

cannot work out how to reference the newly inserted checkbox to set its 

attribute to checked.



My code for doing the insert of the checkbox is:-

Function fnCheckBox(BookMarkName, SetValueTo)

    ' assume the worst

    fnCheckBox = false



    ' return to top of document

    gobjApp.Selection.HomeKey



    ' find first instance of bookmark

    gobjApp.Selection.Find.Execute BookMarkName

    ' loop round all instances of the bookmark

    do until gobjApp.Selection.Find.Found = false

        ' Add a checkbox control to the document

	gobjApp.Selection.FormFields.Add gobjApp.Selection.Range, 71

        if CInt(SetValueTo) = true then

            ' I want to set the properties of the checkbox to checked here

        end if

        ' find next instance of the bookmark

	gobjApp.Selection.Find.Execute BookMarkName

    loop

    fnCheckBox = true

End Function


  Return to Index