> Arghh !
> non tutti i documenti sono uguali, potrei fare lo stesso però
> il processo giusto sarebbe stato il seguente
> - Cerca "Descrizione sintetica"
> - Cerca il seguente "styleName" "Header 1" OR "Header 2"
> - Copio quella selezione
>
> Il problema è la OR perchè perchè non mi pare si riesca a fare una find
L'ho risolto in questa maniera:
SUB SelText2Header
Dim oDoc, sSearchWord
Dim aSrc, oVCur, eParEnum, oCurStart, oCurEnd
DIM oPar, sParagrafo, sParaStyleName, bStart, n, m
oDoc = ThisComponent
sSearchWord = "Scopo e campo"
oCurStart = oDoc.Text.createTextCursor()
oCurEnd = oDoc.Text.createTextCursor()
oVCur = oDoc.CurrentController.getViewCursor()
'-------------------------------- 'loop through all of the paragraphs
in the source document
eParEnum = oDoc.getText().createEnumeration()
bStart = false
oPar = eParEnum.nextElement()
Do While eParEnum.hasMoreElements()
oPar = eParEnum.nextElement()
If oPar.supportsService("com.sun.star.text.Paragraph") Then
sParagrafo = oPar.string
sParaStyleName = oPar.ParaStyleName
' if sParagrafo = sFirstStr and sParaStyleName =
"Heading 1"
then
N = Instr(1,sParagrafo,sSearchWord)
m = Instr(1,sParaStyleName,"Heading 2")
m = Instr(1,sParaStyleName,""Heading 1") + m
if N > 0 and m > 0 then
ovCur.GotoRange(oPar, False)
ocurStart.gotorange(ovCur, false)
ocurStart.gotoNextParagraph(False)
bStart = True
Else IF bStart and m > 0 then
ovCur.GotoRange(oPar, True) 'posiziona inizio
del paragrafo
precedente
ocurEnd.gotorange(ovCur, True)
oCurEnd.gotoPreviousParagraph(False)
oCurEnd.gotoEndOfParagraph(False)
Exit Do
End IF
End IF
end IF
Loop
oVCur.gotoRange(ocurStart, False)
oVCur.gotoRange(ocurEnd, True)
End SUB
Onestamente il passaggio da Cursore (normale) ad Cursore Visule è un
accrocchio per sopperire la mia ignoranza, ma funziona e di meglio non ho
saputo fare.
Se qualcuno ha delle dritte ben vengano
Grazie a tutti.
Guido
--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP
autenticato? GRATIS solo con Email.it: http://www.email.it/f
Sponsor:
Gioca subito al grande social game di Kit Kat! Ogni giorno puoi vincere
viaggi a Cuba e iTunes card per te e i tuoi amici. Gioca adesso
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=9893&d=20091207
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]