Erreur sur macro

michel -  
 michel -
Bonjour, j'ai récupéré sur internet un fichier excel pour un jeu en reseau (travian) ce fichier sert a calculer la distance entre des points (villages) j'ai un problème car une macro ne marche pas tres bien des erreurs je pense dans le codage je m'y connais pas très bien dans les macro j'aurai besoin d'un coup de main et aussi fraudais modifier un peu le fichier excel

sub recup
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelpe r")

msgbox "Allez sur le profil des Natars et appuyer sur Ctrl+A puis Ctrl+C pour copier tout."
rem ----------------------------------------------------------------------

dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$B$1"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())

msgbox ("Dans la prochaine fenetre cochez 'Tabulation', 'Fusionner les séparateurs' et 'Autre'?" & chr(13) & "Dans 'Autre' tapez '(|)' (sans les ')" & chr(13) & "Puis cliquez sur 'ok'"

rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Format"
args3(0).Value = 1

dispatcher.executeDispatch(document, ".uno:PasteSpecial", "", 0, args3())

dim ligne as integer
dim ligne2 as integer
Dim oSheet as Object
dim test as integer
dim formule as string
oSheet = ThisComponent.Sheets.getbyName("Feuille1")

ligne = 1
test = 10002
ligne2 = 1

rem ----------------------------------------------------------------------
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "ToPoint"
args6(0).Value = "$A$1"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args6())

rem ----------------------------------------------------------------------
dim args5(0) as new com.sun.star.beans.PropertyValue
args5(0).Name = "StringName"
args5(0).Value = "=SI(ESTNUM(D1);LIGNE(D1);-1)"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args5())


dim args10(0) as new com.sun.star.beans.PropertyValue
args10(0).Name = "ToPoint"
args10(0).Value = "$A$1"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args10())

rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = "EndCell"
args11(0).Value = "$A$10000"

dispatcher.executeDispatch(document, ".uno:AutoFill", "", 0, args11())

rem ----------------------------------------------------------------------
dim args12(0) as new com.sun.star.beans.PropertyValue
args12(0).Name = "ToPoint"
args12(0).Value = "$A$1:$A$10000"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args12())

oSheet.getCellRangeByName("A10001").formula = "=max($A$1:$A$10000)"

do while ligne < oSheet.getCellRangeByName("A" & test - ligne2).value
if oSheet.getCellRangeByName("A" & ligne).value < 0 then

args2(0).Name = "ToPoint"
args2(0).Value = "$D" & ligne

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())
ligne2 = ligne2 + 1

dispatcher.executeDispatch(document, ".unoeleteRows", "", 0, Array())
else
ligne = ligne + 1
endif
loop

end sub 


A voir également:

2 réponses

Mytå Messages postés 2973 Date d'inscription   Statut Contributeur Dernière intervention   953
 
Salut le forum

Michel, tu parles d'un fichier Excel alors que la macro est pour un fichier OpenOffice.

Mytå
0
michel
 
oups désolé merci d'avoir transféré ma demande
0