Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


Bonjour 
avec ces 2 macros appelées alternativement , je plante Calc au bout de 10 à
50 appels.
j'ai l'impression d'une fuite mémoire, car avant le plantage il y a des
signes anormaux : affichage d'une autre feuille, delay important...
j'appelle la macro Nouvelle Facture avec une liste déroulante ou je choisi
le nom, 
puis la macro Imprimer, celle-ci me crée un pdf et enregistre le document en
cours (Odoc.Store)

quelqu'un aurait une idée?

bonne journée!!

Sub NouvelleFacture (Evt)
dim oDoc as object
dim Feuille as object
Dim oRange As Object
Dim oCellLire as object, oCellEcrire as object
Dim i as Integer
Dim l as Long, ll as Long
Dim itemNum as Integer
Dim Nom as string, Adr1 as string, Adr2 as string, Ville as string, Chambre
as string
oDoc=thiscomponent
Feuille=oDoc.Sheets.getByName("Formules")
itemNum = Evt.Source.SelectedItemPos + 1
oCellLire = Feuille.getCellByPosition(3,9)'timer
l= oCellLire.GetValue
ll = Timer()
l=ll-l
oCellLire = Feuille.getCellByPosition(2,9)'drp impression, est vérifié à
l'ouverture d'une nouvelle facture
if oCellLire.GetValue = 0 AND l>10 then
 i= MsgBox ("La facture n'a pas été enregistrée, continuer?", 4 + 32 + 256,
"Attention")
 if i = 7 then
 exit sub
 End If
 if i = 6 then
oCellEcrire = Feuille.getCellByPosition(3,9)'timer
l = Timer()
oCellEcrire.SetValue(l)
 End If
else 
 oCellLire.SetValue(0)
End If
oCellLire = Feuille.getCellByPosition(2,10) 'num facture
i=oCellLire.Value
Feuille=oDoc.Sheets.getByName("Clients")
oCellLire = Feuille.getCellByPosition(0,itemNum) 'civi
Nom = oCellLire.string & " "
oCellLire = Feuille.getCellByPosition(1,itemNum) 'nom
Nom = Nom & oCellLire.string & " "
oCellLire = Feuille.getCellByPosition(2,itemNum) 'prénom
Nom = Nom & oCellLire.string
oCellLire = Feuille.getCellByPosition(3,itemNum) 'Adr1
Adr1 = oCellLire.string
oCellLire = Feuille.getCellByPosition(4,itemNum) 'Adr2
Adr2 = oCellLire.string
oCellLire = Feuille.getCellByPosition(5,itemNum) 'CP
Ville  = oCellLire.string & " "
oCellLire = Feuille.getCellByPosition(6,itemNum) 'Ville
Ville  = Ville & oCellLire.string
oCellLire = Feuille.getCellByPosition(7,itemNum) 'Chambre
Chambre  = "Chambre " & oCellLire.string
Feuille=oDoc.Sheets.getByName("FactureIndividuelle")
oCellEcrire =  Feuille.getCellByPosition(0,14)
oCellEcrire.SetString("Facture N°" & i)
oCellEcrire =  Feuille.getCellByPosition(5,6)
oCellEcrire.SetString(Nom)
oCellEcrire =  Feuille.getCellByPosition(5,7)
oCellEcrire.SetString(Adr1)
oCellEcrire =  Feuille.getCellByPosition(5,8)
oCellEcrire.SetString(Adr2)
oCellEcrire =  Feuille.getCellByPosition(5,9)
oCellEcrire.SetString(Ville)
oCellEcrire =  Feuille.getCellByPosition(5,10)
oCellEcrire.SetString(Chambre)
oRange = Feuille.getCellRangeByPosition(0,18,0,29)'("A19:A30")
oRange.clearContents(31) 
oRange = Feuille.getCellRangeByPosition(0,32,0,42)'("A33:E42")
oRange.clearContents(31) 
oRange = Feuille.getCellRangeByPosition(5,18,5,29)'("F18:F30")
oRange.clearContents(31) 
oRange = Feuille.getCellRangeByPosition(5,32,5,42)'("F33:F43")
oRange.clearContents(31) 
oRange = Feuille.getCellRangeByPosition(6,18,6,29)'("G19:G30")
oRange.clearContents(31) 
oRange = Feuille.getCellRangeByPosition(6,32,6,42)'("G33:G43")
oRange.clearContents(31) 
oCellLire = Feuille.getCellByPosition(1,20) 'acte
oCellEcrire = Feuille.getCellByPosition(1,20)
oCellEcrire.Setstring(oCellLire.getstring)
End Sub

Sub Imprimer
Dim oDoc As Object
Dim FeuilleDep As Object, FeuilleArr As Object
Dim oCellLire as object, oCellEcrire as object
Dim Args1(2) as new com.sun.star.beans.PropertyValue
Dim Args2(2) as new com.sun.star.beans.PropertyValue
Dim Chemin As String, maDate As String
Dim i as Integer, ExoLig As Integer, numCli As Integer, numFact As Integer
Dim Client as String
Dim DrpModif as integer
oDoc = ThisComponent
FeuilleDep = oDoc.Sheets.getByName("Formules")
oCellLire = FeuilleDep.getCellByPosition(2,8)' DrpModif
DrpModif = oCellLire.getvalue
if DrpModif = 0 then
oCellLire = FeuilleDep.getCellByPosition(2,10) 'NumFacture
numFact = oCellLire.getvalue
oCellLire.setValue(numFact+1)
else 
numFact = DrpModif
End If
oCellLire = FeuilleDep.getCellByPosition(2,8)' DrpModif
oCellLire.SetValue(0)
oCellLire = FeuilleDep.getCellByPosition (2,1) 'chemin
Chemin = oCellLire.getString 
if Right(Chemin,1) <> "/" then
Chemin = Chemin & "/"
End If
oCellLire = FeuilleDep.getCellByPosition (5,5)'année
i = oCellLire.getValue
Chemin = Chemin & i & "/" 
oCellLire = FeuilleDep.getCellByPosition (4,5)'mois
i = oCellLire.getValue
oCellLire = FeuilleDep.getCellByPosition (3,5)'jour
maDate = oCellLire.getValue
oCellLire = FeuilleDep.getCellByPosition (4,5)'mois
maDate = maDate & "/" & oCellLire.getValue
oCellLire = FeuilleDep.getCellByPosition (5,5)'année
maDate = maDate & "/" & oCellLire.getValue
Select Case (i)
case 1
Chemin = Chemin & "janvier/" 
case 2
Chemin = Chemin & "février/" 
case 3
Chemin = Chemin & "mars/" 
case 4
Chemin = Chemin & "avril/" 
case 5
Chemin = Chemin & "mai/" 
case 6
Chemin = Chemin & "juin/" 
case 7
Chemin = Chemin & "juillet/" 
case 8
Chemin = Chemin & "août/" 
case 9
Chemin = Chemin & "septembre/" 
case 10
Chemin = Chemin & "octobre/" 
case 11
Chemin = Chemin & "novembre/" 
case 12
Chemin = Chemin & "décembre/" 
End Select
oCellLire = FeuilleDep.getCellByPosition (3,7) 'nom
Chemin = Chemin &  oCellLire.getString
Client = oCellLire.getString
oCellLire = FeuilleDep.getCellByPosition (4,7) 'prénom
if Len(oCellLire.getString)>1  Then
Client = Client & " " & oCellLire.getString
Chemin = Chemin & "_" & oCellLire.getString
End If
Chemin = Replace (Chemin," ","_")
Chemin = Chemin & "_" & numFact
Chemin = Chemin & ".pdf"
FeuilleDep = oDoc.Sheets.getByName("FactureIndividuelle")
oCellEcrire =  FeuilleDep.getCellByPosition(6,43)'total
oCellEcrire.Formula = "=sum(G18:G43)"
oCellLire = FeuilleDep.getCellRangeByPosition(0,0,6,52)
Args1(0).Name = "Selection"
Args1(0).Value = oCellLire
Args1(1).Name = "SelectPdfVersion"
Args1(1).Value = 1
Args2(0).Name = "FilterName"
Args2(0).Value = "calc_pdf_Export"
Args2(1).Name = "FilterData"
Args2(1).Value = Args1()
'Args2(2).Name = "SelectPdfVersion"
'Args2(2).Value = 1
Chemin=convertToUrl(Chemin)
oDoc.storeToURL(Chemin,Args2())
oDoc.store
MsgBox(Client, 0, "Facture Imprimée")
End Sub





--
View this message in context: http://nabble.documentfoundation.org/plantage-Calc-tp4097451.html
Sent from the Users mailing list archive at Nabble.com.

-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.