D. Michel Morelli wrote:
Perche' il file mi viene "spedito" tramite Firefox e non posso farmi
spedire un stw perche' il programma "che spedisce" digerisce gli sxw.
Ma che roba è?
Spiega spiega..
Mi sono dannato con il pulsante "OK" :) e quindi allego la macro con
(relativa) soddisfazione.
La macro prende i nomi dei segnalibri presenti nel documento e li
utilizza per creare una maschera in cui inserire i dati che poi vengono
inseriti, tramite cursori, nel testo. I segnalibri rimangono e la macro
si può anche eseguire più volte.
Ciao,
--
MC
REM ***** BASIC *****
Dim oDialog1
Dim oDlgModel
Dim Nomi()
Dim Valori()
Dim n
Sub Main
Dim oBookmarks
Dim oBookmark
oDoc = ThisComponent
' Salvo i nomi dei segnalibri
oBookMarks = oDoc.getBookmarks()
Nomi() = oBookmarks.ElementNames()
n = oBookMarks.Count-1
Redim Valori(n)
' creo il dialogo
oDlgModel = CreateUnoService("com.sun.star.awt.UnoControlDialogModel")
with oDlgModel
.PositionX = 100 : .PositionY = 10
.Width = 150 : .Height = 80+20*n
end with
for i=0 to n
' inserisco l'etichetta
InserisciControllo("com.sun.star.awt.UnoControlFixedTextModel",_
Format(i,"lbl_00"),Nomi(i),12,50,10,10+20*i)
'inserisco il controllo
InserisciControllo("com.sun.star.awt.UnoControlEditModel",_
Nomi(i)," ",12,50,70,10+20*i)
next
' questo va fatto prima di chiamare DlgTool_Button
oDialog1 = CreateUnoService("com.sun.star.awt.UnoControlDialog")
oDialog1.setModel(oDlgModel)
'
' Presa da http://www.oooforum.org/forum/viewtopic.phtml?t=3130
' di Danny Brewer
'
DlgTool_Button( 60, 40+20*n, 40, 12, "OK","OK","OK")
Dim oWindow
oWindow = CreateUnoService("com.sun.star.awt.Toolkit")
oDialog1.createPeer(oWindow, null)
oDialog1.execute()
' aggiorna i valori
for i=0 to n
oBookmark = oBookmarks.getByName(Nomi(i))
oCursor = oDoc.Text.createTextCursorByRange(oBookmark.Anchor)
oCursor.string = Valori(i)
oCursor.gotoEndOfParagraph(false)
next
End Sub
Sub InserisciControllo(Tipo,Nome,Etichetta,Alt,Larg,Px,Py)
oControl = oDlgModel.CreateInstance(Tipo)
with oControl
.Name = Nome
if .ImplementationName <> "stardiv.Toolkit.UnoControlEditModel"
then
.Label = Etichetta
.VerticalAlign = 1
end if
.Height = Alt : .Width = Larg
.PositionX = Px : .PositionY = Py
end with
oDlgModel.insertByName(Nome, oControl)
End Sub
Sub OK_actionPerformed( oEvent )
' salvo i valori
for i=0 to n
oControl = oDialog1.getcontrol(Nomi(i))
Valori(i) = oControl.Text
next
' chiudo il dialogo
oDialog1.EndExecute()
End Sub
'------
' Call this to place a new button on the dialog box.
'
Sub DlgTool_Button( x As Long, y As Long, width As Long, height As Long,_
cName As String, cCaption As String,_
Optional cEventListenerName As String )
If x < 0 Then
x = oDlgModel.Width + x - width
EndIf
If y < 0 Then
y = oDlgModel.Height + y - height
EndIf
oButtonModel = oDlgModel.createInstance(
"com.sun.star.awt.UnoControlButtonModel" )
' Initialize the button model's properties.
with oButtonModel
.PositionX = x : .PositionY = y
.Width = width : .Height = height
.Name = cName : .TabIndex = nNumControls
.Label = cCaption
end with
oDlgModel.insertByName( cName, oButtonModel )
oButtonControl = oDialog1.getControl( cName )
' Buttons always get an action listener.
' You must create a procedure with the right name to receive the event.
If IsMissing( cEventListenerName ) Then
cEventListenerName = cName
EndIf
oActionListener = CreateUnoListener( cEventListenerName + "_",_
"com.sun.star.awt.XActionListener" )
oButtonControl.addActionListener( oActionListener )
End Sub
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]