OK I have something new : it works
Well, at least it works for me : I want to fill in the unique prompt of my Word document, and this document is using several LiveOffice objects created thanks to a WebI doc.
The sample code (here) in the forum suggested to load the dll file. Once done, you are able to use the CrystalAddin class in your VBA code.
But that’s not enough : you also have to add the webi_module 1.0 Type Library in your project references
Now, you’re ready to code : in my Word document, I created a new class module named loClass, with the following code :
Public WithEvents loEvent As CrystalAddin
Private Sub loEvent_AfterDocumentLoad(ByVal doc As CRYSTAL_ADDIN_FRAMEWORKLib.IDocument)
Dim loObj, loPrompt, loPromptValues As Object
' Update prompt value for each LiveOffice object
Dim i As Integer
For i = 1 To loEvent.LiveObjects.Count
Set loObj = loEvent.LiveObjects.Item(i - 1)
Set loPrompt = loObj.WebiAddinPrompts.GetItem(0)
Set loPromptValues = loPrompt.CurrentValues.GetItem(0)
' set your own value using Value property
loPromptValues.Value = "Enter_the_value_here"
Next
'Refresh
loEvent.LiveObjects.Refresh
End Sub
Then I added this code in ThisDocument :
Option Explicit
Dim lo As New loClass
Private Sub Document_Close()
Set lo.loEvent = Nothing
End Sub
Private Sub Document_Open()
Set lo.loEvent = Application.COMAddIns("CrystalOfficeAddins.CrystalComAddin.7").Object
End Sub
And that’s all : now my LiveOffice objects are updated with the specified value just after the loading of the doc
I hope this could help !
djikstra (BOB member since 2004-03-23)