1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| Option Explicit
Dim oDlg As Object
Sub OuvrirDialog
Dim bibli As Object, monDialogue As Object
DialogLibraries.LoadLibrary("Standard")
bibli = DialogLibraries.GetByName("Standard")
monDialogue = bibli.GetByName("Dialog1")
oDlg = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
oDlg.Execute
End Sub
Sub monFormulaire
Dim oFeuille As Object, oCursor As Object
Dim sVar1 As Object, sVar2 As Object, sVar3 As Object
Dim sNom1 As Object, sNom2 As Object, sNom3 As Object
Dim oDoc As Object, oCol As Object
Dim indexCol As Long, indexFeuille As Integer
Dim indexLigne As Long
Dim ligneFin As Long
sNom1 = oDlg.getControl("TextField1")
sNom2 = oDlg.getControl("TextField2")
sNom3 = oDlg.GetControl("TextField3")
indexFeuille = 0
oDoc = thisComponent
oFeuille = oDoc.sheets.getByIndex(indexFeuille)
oCol = oFeuille.getColumns.getByName("A")
indexCol = oCol.getRangeAddress.startColumn
indexLigne = acGetIndexLigneFin(indexFeuille, indexCol)
sVar1 = oFeuille.getCellRangeByName("A" & indexLigne + 2)
sVar1.string = sNom1.Text
sVar2 = oFeuille.getCellRangeByName("B" & indexLigne + 2)
sVar2.string = sNom2.Text
sVar3 = oFeuille.getCellRangeByName("C" & indexLigne + 2)
sVar3.string = sNom3.Text
sNom1.text = ""
sNom2.text = ""
sNom3.text = ""
End Sub
'************************************************************ 02/12/09
'**** Retourne l'index de la ligne
'**** de la dernière cellule non vide de la colonne indexCol
'*********************************************************************
Function acGetIndexLigneFin(iFeuille as integer, iCol as long) As Long
Dim oDoc As Object, oFeuille As Object, oCol As Object
Dim dscCherche As Object
dim oCell as object
Dim oCellAdresse As object
Dim ligneMaxi As Long
Dim ligneFin As Long
ligneFin = -1 ' par défaut, retourne -1
oDoc = thisComponent
oFeuille = oDoc.sheets.getByIndex(iFeuille)
oCol = oFeuille.getColumns.getByIndex(iCol)
' Se positionner sur la dernière cellule de la colonne
ligneMaxi = oFeuille.rangeAddress.endRow
oCell = oFeuille.getCellByPosition(0,ligneMaxi)
oDoc.currentController.select(oCell)
' Effectuer une recherche vers le haut
dscCherche = oCol.createSearchDescriptor
With dscCherche
.SearchString = "."
.SearchBackwards = true
.SearchRegularExpression = true
End With
oCell = oCol.findFirst(dscCherche)
If (isNull(oCell) = false) Then
' Cellule trouvée
oCellAdresse = oCell.cellAddress
ligneFin = oCellAdresse.row
oDoc.currentController.select(oCell)
End If
acGetIndexLigneFin = ligneFin
End Function |
Partager