bonjour,
Je veux ecrire une macro sous openoffice qui me créerai plusieurs nouvelles feuilles avec des noms différents mais je ne vois pas vraiment comment faire. Quelqu'un peut-il m'aider.
Merci
Sub AddSheet()
Dim myDoc as Object, mySheets as Object
Dim name1 as String, name2 as string
myDoc = thisComponent
mySheets = myDoc.Sheets
' le nom de la feuille après laquelle on crée la nouvelle
name1 = InputBox("Insérer une feuille après : ")
name2 = InputBox("La feuille crée aura pour nom : ")
mySheets.insertNewByName(name2, getIndexByName(mySheets,name1) +1)
End Sub
Sub AddSheet()
Dim myDoc as Object, mySheets as Object
Dim name as String
myDoc = thisComponent
mySheets = myDoc.Sheets
name = InputBox("La feuille crée aura pour nom : ")
mySheets.insertNewByName(name2, -1)
End Sub
Sub AddSheet()
Dim myDoc as Object, mySheets as Object
Dim name1 as String, name2 as string
myDoc = thisComponent
mySheets = myDoc.Sheets
'le nom de la feuille après laquelle on crée la nouvelle
name1 = InputBox("Insérer une feuille après : ")
name2 = InputBox("La feuille crée aura pour nom : ")
mySheets.insertNewByName(name2, _
getIndexByName(mySheets, name1) +1)
End Sub
'en cas de succes la fonction renvoie l'index correspondant
'en cas d'échec elle affiche un message d'erreur
'et renvoie un index hors-limite (la feuille est ajouter à la fin)
Function getIndexByName(collection As Object, _
theName As String) As Long
Dim i As Long
for i = 0 to collection.Count -1
if collection(i).Name = theName then
getIndexByName = i ' renvoyer l'index correspondant au nom
Exit Function
end if
next
MsgBox("Feuille inexistante : " & theName & ". La nouvelle feuille a été ajoutée à la fin.", 16, "Collection")
getIndexByName = -100 ' la feuille est ajoutée à la fin si theName inexistant
End Function
myDoc = thisComponent
getIndexByName.
Sub Macro2() ' ' Macro2 Macro ' Macro enregistrée le 17/09/2005 par lami ' ' With ActiveSheet.PageSetup .PrintTitleRows = "" .PrintTitleColumns = "" End With ActiveSheet.PageSetup.PrintArea = "" With ActiveSheet.PageSetup .LeftHeader = "" .CenterHeader = "" .RightHeader = "" .LeftFooter = "" .CenterFooter = "" .RightFooter = "" .LeftMargin = Application.InchesToPoints(0.787401575) .RightMargin = Application.InchesToPoints(0.787401575) .TopMargin = Application.InchesToPoints(0.984251969) .BottomMargin = Application.InchesToPoints(0.984251969) .HeaderMargin = Application.InchesToPoints(0.4921259845) .FooterMargin = Application.InchesToPoints(0.4921259845) .PrintHeadings = False .PrintGridlines = False .PrintComments = xlPrintNoComments .PrintQuality = 96 .CenterHorizontally = False .CenterVertically = False .Orientation = xlLandscape .Draft = False .PaperSize = xlPaperA4 .FirstPageNumber = xlAutomatic .Order = xlDownThenOver .BlackAndWhite = False .Zoom = 100 .PrintErrors = xlPrintErrorsDisplayed End With End Sub
Sub Macro2() ActiveSheet.PageSetup.Orientation = xlLandscape End Sub
sub test
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.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "StringName"
args1(0).Value = "Azerty"
dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:JumpToNextCell", "", 0, Array())
end sub
sub test2 ()
ThisComponent.Sheets.getByName("Feuille1").getCellByPosition(0,0).string="Azerty"
end sub
Vous n'aimez pas le lifting de Facebook ? Le site Mashable propose cinq étapes pour revenir à l'ancienne présentation du réseau social.