12 messages in org.openoffice.fr.progRe: [prog] Pointer doc sans l'ouvrir
FromSent OnAttachments
Laurent GodardOct 15, 2004 8:44 am 
JovialOct 15, 2004 8:44 am 
Alain NowakOct 15, 2004 8:48 am 
JovialOct 15, 2004 10:16 am 
Alain NowakOct 15, 2004 10:20 am 
JovialOct 15, 2004 10:50 am 
JovialOct 15, 2004 5:46 pm 
Laurent GodardOct 16, 2004 12:12 am 
Bernard MarcellyOct 16, 2004 3:43 am 
JovialOct 16, 2004 7:43 am 
JovialOct 19, 2004 3:42 pm 
JovialOct 20, 2004 1:48 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [prog] Pointer doc sans l'ouvrirActions...
From:Jovial (luck@free.fr)
Date:Oct 20, 2004 1:48:06 am
List:org.openoffice.fr.prog

J'ai trouvé une solution sur la liste anglaise qui semble fonctionner DocCible.currentcontroller.frame.containerwindow.toFront : me permet d'activer la fenêtre de DocCible (voir macro)

Donc maintenant il m'est possible naviguer entre 2 documents

D'après mes essais Global ne fonctionne qu'à travers les modules d'un même document, je pense qu'il suffit de lire les variables d'un document de les réatribuer dans un autre. Il me reste à pouvoir afficher un document caché( Hidden) Et j'aimerai savoir si a partir d'un MonDocument (en utilisant une de ses macros) on peut activer une macro de DocCible

Merci de votre aide

JeanLuc

Ci dessous ma macro actualisée + une autre macro de DannyB récupérée sur liste anglaise et qui traite le problème de manière plus developpé

Sub OuvrirJournal dim DocCible as object, unDoc as object dim arg(0) as new com.sun.star.beans.PropertyValue DocOuvert = 0

'arg(0).Name="Hidden" 'argument pour rendre le document invisible à l'utilisateur (non utilisé) 'arg(0).Value=True URLfichier= ConvertToUrl("C:\Mes documents\JournalFactures.sxc") lesDocs=stardesktop.components on error resume next laCollection = lesDocs.createEnumeration do while laCollection.hasMoreElements unDoc=laCollection.nextElement DocURL = unDoc.URL if DocURL = URLfichier then DocOuvert = 1 DocCible = unDoc 'print DocCible.URL exit do end if loop

if DocOuvert = 0 then Msgbox "on charge" DocCible=stardesktop.loadComponentFromURL(URLfichier, "_blank", 0, arg()) Else Msgbox "le document est déja chargé: on l'active" end if

LesFeuillesCible = DocCible.sheets FeuilleCible = LesFeuillesCible.getByName("Feuille1")

CelluleCible1 = FeuilleCible.GetCellRangeByName("A1") msgbox CelluleCible1.formula Unezone = FeuilleCible.getCellRangeByName("A2:C5") DocCible.currentcontroller.frame.containerwindow.toFront DocCible.CurrentController.Select(UneZone)

End sub

Macro de DannyB http://www.oooforum.org/forum/viewtopic.php?t=3712&start=0&postdays=0&postorder=asc&highlight=createenumeration <http://www.oooforum.org/forum/viewtopic.php?t=3712&start=0&postdays=0&postorder=asc&highlight=createenumeration>

Sub Main oComponents = StarDesktop.getComponents()

' Show me how many total components are open? nCount = 0 oComponentWalker = oComponents.*createEnumeration*() Do While oComponentWalker.hasMoreElements() oComponent = oComponentWalker.nextElement() nCount = nCount + 1 Loop Print "There are "; nCount; " components open."

' Walk through the components looking for documents of a specific type. oComponentWalker = oComponents.*createEnumeration*() Do While oComponentWalker.hasMoreElements() oComponent = oComponentWalker.nextElement() ' See if component is a document. ' Any com.sun.star.document.OfficeDocument supports XModel. ' Of course, we could have just checked for the service OfficeDocument, ' see the Drawing example below for how to check for a service. If HasUnoInterfaces( oComponent, "com.sun.star.frame.XModel" ) Then ' It will have this particular interface if it is a spreadsheet document. If HasUnoInterfaces( oComponent, "com.sun.star.sheet.XSpreadsheetDocument" ) Then

' Notify me if we found a spreadsheet document has a sheet named "Sheet2", ' and cell C2 of that sheet contains the text "Meow Mix". oSheets = oComponent.getSheets() If oSheets.hasByName( "Sheet2" ) Then oSheet = oSheets.getByName( "Sheet2" ) If oSheet.getCellByPosition( 2, 1 ).getFormula() = "Meow Mix" Then MsgBox( "Found the componenet, which is a spreadsheet, which has a sheet names Sheet2, whose cell C2 contains Meow Mix." ) EndIf EndIf ' If it has Sheet2 EndIf ' If it is a spreadsheet

' If the component is Untitled, that is, has not been saved, then notify me. If Not oComponent.hasLocation() Then MsgBox( "Untitled component found." ) EndIf ' if it is untitled.

' If the document is saved, and is C:\MYDOC.SXC If oComponent.hasLocation() Then cURL = oComponent.getLocation() cFile = ConvertFromURL( cURL ) If UCase( cFile ) = "C:\MYDOC.SXC" Then MsgBox( "Found the document C:\MYDOC.SXC" ) EndIf EndIf

' It will have this particular SERVICE if it is a drawing document. If oComponent.SupportsService( "com.sun.star.drawing.DrawingDocument" ) Then

' Notify me if we found a drawing document that has a shape named "Apple Jacks" ' on its second page. oDrawPages = oComponent.getDrawPages() if oDrawPages.getCount() >= 2 Then oDrawPage = oDrawPages.getByIndex( 1 ) For nShape = 0 To oDrawPage.getCount() - 1 oShape = oDrawPage.getByIndex( i ) If oShape.getName() = "Apple Jacks" Then MsgBox( "Found the component, which is a drawing, which has a shape named Apple Jacks on its second page." ) EndIf Next EndIf ' If it has 2 or more pages EndIf ' If it is a drawing EndIf ' if it has XModel (which probably means it is an OfficeDocument) Loop End Sub