Buenas a todos.
Estamos un poco perdidos en mi empresa de cómo implementar Oo. Os explico. Nosotros utilizamos Lotus Notes para muchas iniciativas de la empresa. A través de Lotus tenemos aplicaciones que llaman a Excel y nos extraen directamente tablas con datos, graficas, escritos... Todo funciona a la perfección. Hoy en día, abordamos el cambio a Oo, y teniendo en cuenta que ninguno somos especialistas informáticos, sino peligrosos autodidactas, se nos abren unas dudas inmensas.
En un principio pensábamos que simplementa variando la llamada que hacía Lotus a excel por una llamada a Calc, se solventaría. Por lo que ya he leído, ésto no será posible porque excel trabaja en VisualBasic y Calc en Basic (el cual desconocemos). ¿Qué podemos hacer? Os paso un código entero. Está realizado de forma artesanal y muy repetitiva, pero es cómo lo tenemos y nos funciona. ¿Habría que hacer muchos cambios? Ayuda por favor. Muchas Gracias
Sub Click(Source As Button)
Dim db As notesdatabase
Dim ses As New NotesSession
Set db = ses.currentdatabase
Dim docP As notesdocument
Dim obj As Variant
Dim apli As Variant
cont=0
Set vis = db.getview("IND-QUEJA")
Set doc= vis.getfirstdocument
Set obj = CreateObject("Excel.Application")
Set apli = obj.Application
apli.Visible=True
Set workb= apli.Workbooks.Add()
Call workb.Worksheets.Add() 'añadir hojas al libro
Call workb.Worksheets.Add() 'puede que no tenga como predeterminado 3 hojas en el libro y solo tenga una
Call workb.Worksheets.Add()
Call workb.Worksheets.Add()
Set works = workb.Worksheets(1)
Set works2 = workb.Worksheets(2)
Set works3 = workb.Worksheets(3)
Set works4 = workb.Worksheets(4)
Call workb.Activate
Call works.Activate
Call works2.Activate
Call works3.Activate
Call works4.Activate
'works.name="quejas2004"
'works2.name="quejas2005"
works.name="quejas2006"
works2.name="quejas2007"
works3.name="quejas2008"
v=1
v2=1
v3=1
v4=1
v1pend=0
v2pend=0
v3pend=0
v4pend=0
sumpendientes1=0
sumpendientes2=0
sumpendientes3=0
sumpendientes4=0
sumtodas1=0
sumtodas2=0
sumtodas3=0
sumtodas4=0
With works
.Cells(1,1).Value="Ca/MA"
.Columns(1).ColumnWidth=6
.Cells(1,2).Value="Año apertura"
.Columns(3).ColumnWidth=10
.Cells(1,3).Value="Num IRP"
.Columns(5).ColumnWidth=25
.Cells(1,4).Value="Estado"
.Columns(5).ColumnWidth=15
.Cells(1,5).Value="F. Apertura IRP"
.Columns(5).ColumnWidth=10
.Cells(1,6).Value="F. Cierre IRP"
.Columns(5).ColumnWidth=10
.Cells(1,7).Value="edad Todos"
.Columns(5).ColumnWidth=8
.Cells(1,8).Value="edad pendiente"
.Columns(5).ColumnWidth=8
End With
With works2
.Cells(1,1).Value="Ca/MA"
.Columns(1).ColumnWidth=6
.Cells(1,2).Value="Año apertura"
.Columns(3).ColumnWidth=10
.Cells(1,3).Value="Num IRP"
.Columns(5).ColumnWidth=25
.Cells(1,4).Value="Estado"
.Columns(5).ColumnWidth=15
.Cells(1,5).Value="F. Apertura IRP"
.Columns(5).ColumnWidth=10
.Cells(1,6).Value="F. Cierre IRP"
.Columns(5).ColumnWidth=10
.Cells(1,7).Value="edad Todos"
.Columns(5).ColumnWidth=8
.Cells(1,8).Value="edad pendiente"
.Columns(5).ColumnWidth=8
End With
With works3
.Cells(1,1).Value="Ca/MA"
.Columns(1).ColumnWidth=6
.Cells(1,2).Value="Año apertura"
.Columns(3).ColumnWidth=10
.Cells(1,3).Value="Num IRP"
.Columns(5).ColumnWidth=25
.Cells(1,4).Value="Estado"
.Columns(5).ColumnWidth=15
.Cells(1,5).Value="F. Apertura IRP"
.Columns(5).ColumnWidth=10
.Cells(1,6).Value="F. Cierre IRP"
.Columns(5).ColumnWidth=10
.Cells(1,7).Value="edad Todos"
.Columns(5).ColumnWidth=8
.Cells(1,8).Value="edad pendiente"
.Columns(5).ColumnWidth=8
End With
'With works4
' .Cells(1,1).Value="Ca/MA"
' .Columns(1).ColumnWidth=6
' .Cells(1,2).Value="Año apertura"
' .Columns(3).ColumnWidth=10
' .Cells(1,3).Value="Num IRP"
' .Columns(5).ColumnWidth=25
' .Cells(1,4).Value="Estado"
' .Columns(5).ColumnWidth=15
' .Cells(1,5).Value="F. Apertura IRP"
' .Columns(5).ColumnWidth=10
' .Cells(1,6).Value="F. Cierre IRP"
' .Columns(5).ColumnWidth=10
' .Cells(1,7).Value="edad Todos"
' .Columns(5).ColumnWidth=8
' .Cells(1,8).Value="edad pendiente"
' .Columns(5).ColumnWidth=8
'
'End With
While Not doc Is Nothing
'Hoja 1
If doc.Form(0)="Pal" And doc.Estado(0)<>"NoProblema" And doc.Borrado(0)<>"Si" Then
If Year(doc.fechaIdent(0))=2006 Then
v=v+1
With works
If doc.ProMA(0)="Si" Then
.Cells(v,1).Value="MA"
Else
.Cells(v,1).Value="CA"
End If
mes=Month(doc.FechaIdent(0))
Select Case mes
Case 1,2,3
trimestre="1"
Case 4,5,6
trimestre="2"
Case 7,8,9
trimestre="3"
Case 10,11,12
trimestre="4"
End Select
.Cells(v,2).Value=Cstr(Year(doc.FechaIdent(0)))+"-"+trimestre
num=doc.NumeroIRPEV(0)
If num="" Then
.Cells(v,3).Value="Borrador"
Else
.Cells(v,3).Value=doc.NumeroIRPEV(0)
End If
If doc.Estado(0)="Inicio" Or doc.Estado(0)="PdteInicio"_
Or doc.Estado(0)="Rechazo" Or (doc.Estado(0)="PendAceptacion" And doc.Solucionado(0)="No") Then
est="F. Identificación"
Elseif doc.Estado(0)="EvaluacionInicial" Then
est="Pdte. Evaluación Inicial"
Elseif doc.Estado(0)="Resolucion" Then
est="Pdte. Solución"
Elseif (doc.Estado(0)="PendAceptacion" And doc.Solucionado(0)="Si")_
Or (doc.Estado(0)="Pendiente" And doc.Solucionado(0)="No") Then
est="Pdte. Aceptación por Supervisor"
Elseif doc.Estado(0)="Responsable" Then
est="Pdte. Aceptación por Evaluador"
Elseif doc.Estado(0)="Cierre" Then
If doc.EvalFJP(0)<>"Si" And doc.EvalFJP(0)<>"No" Then
est="Pdte. Cierre"
Else
est="Pdte. Evaluación Final"
End If
Elseif doc.Estado(0)="NoProblema" Then
est="Anulado"
Else
est=doc.Estado(0)
End If
Print "Procesando IRP: "+doc.NumeroIRPV(0)+" "+est
.Cells(v,4).Value=est
Set hoy=New notesdatetime( Today )
Set FC=Nothing
If est="Cerrado" Or est="Anulado" Then
Set FC=New notesdatetime(doc.FechaCierre(0))
End If
Set FA=Nothing
Set FA=New notesdatetime(doc.FechaIdent(0))
.Cells(v,5).Value=Format(doc.FechaIdent(0),"dd/mmm/yyyy")
If est="Cerrado" Then
dif=FC.TIMEDIFFERENCE(FA)
.Cells(v,6).Value=Format(doc.fechacierre(0),"dd/mmm/yyyy")
Else
dif=hoy.TIMEDIFFERENCE(FA)
.Cells(v,6).Value=""
End If
If dif<>0 Then
tiempo=Round(dif/60/60/24,0)
Else
tiempo=0
End If
sumtodas1=sumtodas1+tiempo
.Cells(v,7).Value=tiempo
If est<>"Cerrado" Then
.Cells(v,8).Value=tiempo
sumpendientes1=sumpendientes1+tiempo
v1Pend=v1pend+1
End If
End With
End If
End If
'hoja 2
If doc.Form(0)="Pal" And doc.Estado(0)<>"NoProblema" And doc.Borrado(0)<>"Si" Then
If Year(doc.fechaIdent(0))=2007 Then
v2=v2+1
With works2
If doc.ProMA(0)="Si" Then
.Cells(v2,1).Value="MA"
Else
.Cells(v2,1).Value="CA"
End If
mes=Month(doc.FechaIdent(0))
Select Case mes
Case 1,2,3
trimestre="1"
Case 4,5,6
trimestre="2"
Case 7,8,9
trimestre="3"
Case 10,11,12
trimestre="4"
End Select
.Cells(v2,2).Value=Cstr(Year(doc.FechaIdent(0)))+"-"+trimestre
num=doc.NumeroIRPEV(0)
If num="" Then
.Cells(v2,3).Value="Borrador"
Else
.Cells(v2,3).Value=doc.NumeroIRPEV(0)
End If
If doc.Estado(0)="Inicio" Or doc.Estado(0)="PdteInicio"_
Or doc.Estado(0)="Rechazo" Or (doc.Estado(0)="PendAceptacion" And doc.Solucionado(0)="No") Then
est="F. Identificación"
Elseif doc.Estado(0)="EvaluacionInicial" Then
est="Pdte. Evaluación Inicial"
Elseif doc.Estado(0)="Resolucion" Then
est="Pdte. Solución"
Elseif (doc.Estado(0)="PendAceptacion" And doc.Solucionado(0)="Si")_
Or (doc.Estado(0)="Pendiente" And doc.Solucionado(0)="No") Then
est="Pdte. Aceptación por Supervisor"
Elseif doc.Estado(0)="Responsable" Then
est="Pdte. Aceptación por Evaluador"
Elseif doc.Estado(0)="Cierre" Then
If doc.EvalFJP(0)<>"Si" And doc.EvalFJP(0)<>"No" Then
est="Pdte. Cierre"
Else
est="Pdte. Evaluación Final"
End If
Elseif doc.Estado(0)="NoProblema" Then
est="Anulado"
Else
est=doc.Estado(0)
End If
Print "Procesando IRP: "+doc.NumeroIRPV(0)+" "+est
.Cells(v2,4).Value=est
Set hoy=New notesdatetime( Today )
Set FC=Nothing
If est="Cerrado" Or est="Anulado" Then
Set FC=New notesdatetime(doc.FechaCierre(0))
End If
Set FA=Nothing
Set FA=New notesdatetime(doc.FechaIdent(0))
.Cells(v2,5).Value=Format(doc.FechaIdent(0),"dd/mmm/yyyy")
If est="Cerrado" Then
dif=FC.TIMEDIFFERENCE(FA)
.Cells(v2,6).Value=Format(doc.fechacierre(0),"dd/mmm/yyyy")
Else
dif=hoy.TIMEDIFFERENCE(FA)
.Cells(v2,6).Value=""
End If
If dif<>0 Then
tiempo=Round(dif/60/60/24,0)
Else
tiempo=0
End If
sumtodas2=sumtodas2+tiempo
.Cells(v2,7).Value=tiempo
If est<>"Cerrado" Then
.Cells(v2,8).Value=tiempo
sumpendientes2=sumpendientes2+tiempo
v2Pend=v2pend+1
End If
End With
End If
End If
'hoja 3
If doc.Form(0)="Pal" And doc.Estado(0)<>"NoProblema" And doc.Borrado(0)<>"Si" Then
If Year(doc.fechaIdent(0))=2008 Then
v3=v3+1
With works3
If doc.ProMA(0)="Si" Then
.Cells(v3,1).Value="MA"
Else
.Cells(v3,1).Value="CA"
End If
mes=Month(doc.FechaIdent(0))
Select Case mes
Case 1,2,3
trimestre="1"
Case 4,5,6
trimestre="2"
Case 7,8,9
trimestre="3"
Case 10,11,12
trimestre="4"
End Select
.Cells(v3,2).Value=Cstr(Year(doc.FechaIdent(0)))+"-"+trimestre
num=doc.NumeroIRPEV(0)
If num="" Then
.Cells(v3,3).Value="Borrador"
Else
.Cells(v3,3).Value=doc.NumeroIRPEV(0)
End If
If doc.Estado(0)="Inicio" Or doc.Estado(0)="PdteInicio"_
Or doc.Estado(0)="Rechazo" Or (doc.Estado(0)="PendAceptacion" And doc.Solucionado(0)="No") Then
est="F. Identificación"
Elseif doc.Estado(0)="EvaluacionInicial" Then
est="Pdte. Evaluación Inicial"
Elseif doc.Estado(0)="Resolucion" Then
est="Pdte. Solución"
Elseif (doc.Estado(0)="PendAceptacion" And doc.Solucionado(0)="Si")_
Or (doc.Estado(0)="Pendiente" And doc.Solucionado(0)="No") Then
est="Pdte. Aceptación por Supervisor"
Elseif doc.Estado(0)="Responsable" Then
est="Pdte. Aceptación por Evaluador"
Elseif doc.Estado(0)="Cierre" Then
If doc.EvalFJP(0)<>"Si" And doc.EvalFJP(0)<>"No" Then
est="Pdte. Cierre"
Else
est="Pdte. Evaluación Final"
End If
Elseif doc.Estado(0)="NoProblema" Then
est="Anulado"
Else
est=doc.Estado(0)
End If
Print "Procesando IRP: "+doc.NumeroIRPV(0)+" "+est
.Cells(v3,4).Value=est
Set hoy=New notesdatetime( Today )
Set FC=Nothing
If est="Cerrado" Or est="Anulado" Then
Set FC=New notesdatetime(doc.FechaCierre(0))
End If
Set FA=Nothing
Set FA=New notesdatetime(doc.FechaIdent(0))
.Cells(v3,5).Value=Format(doc.FechaIdent(0),"dd/mmm/yyyy")
If est="Cerrado" Then
dif=FC.TIMEDIFFERENCE(FA)
.Cells(v3,6).Value=Format(doc.fechacierre(0),"dd/mmm/yyyy")
Else
dif=hoy.TIMEDIFFERENCE(FA)
.Cells(v3,6).Value=""
End If
If dif<>0 Then
tiempo=Round(dif/60/60/24,0)
Else
tiempo=0
End If
sumtodas3=sumtodas3+tiempo
.Cells(v3,7).Value=tiempo
If est<>"Cerrado" Then
.Cells(v3,8).Value=tiempo
sumpendientes3=sumpendientes3+tiempo
v3Pend=v3pend+1
End If
End With
End If
End If
'hoja 4
' If doc.Form(0)="Pal" And doc.Estado(0)<>"NoProblema" And doc.Borrado(0)<>"Si" Then
' If Year(doc.fechaIdent(0))=2007 Then
' v4=v4+1
' With works4
' If doc.ProMA(0)="Si" Then
' .Cells(v4,1).Value="MA"
' Else
' .Cells(v4,1).Value="CA"
' End If
' mes=Month(doc.FechaIdent(0))
' Select Case mes
' Case 1,2,3
' trimestre="1"
' Case 4,5,6
' trimestre="2"
' Case 7,8,9
' trimestre="3"
' Case 10,11,12
' trimestre="4"
' End Select
' .Cells(v4,2).Value=Cstr(Year(doc.FechaIdent(0)))+"-"+trimestre
' num=doc.NumeroIRPEV(0)
' If num="" Then
' .Cells(v4,3).Value="Borrador"
' Else
' .Cells(v4,3).Value=doc.NumeroIRPEV(0)
' End If
'
' If doc.Estado(0)="Inicio" Or doc.Estado(0)="PdteInicio"_
' Or doc.Estado(0)="Rechazo" Or (doc.Estado(0)="PendAceptacion" And doc.Solucionado(0)="No") Then
' est="F. Identificación"
' Elseif doc.Estado(0)="EvaluacionInicial" Then
' est="Pdte. Evaluación Inicial"
' Elseif doc.Estado(0)="Resolucion" Then
' est="Pdte. Solución"
' Elseif (doc.Estado(0)="PendAceptacion" And doc.Solucionado(0)="Si")_
' Or (doc.Estado(0)="Pendiente" And doc.Solucionado(0)="No") Then
' est="Pdte. Aceptación por Supervisor"
' Elseif doc.Estado(0)="Responsable" Then
' est="Pdte. Aceptación por Evaluador"
' Elseif doc.Estado(0)="Cierre" Then
' If doc.EvalFJP(0)<>"Si" And doc.EvalFJP(0)<>"No" Then
' est="Pdte. Cierre"
' Else
' est="Pdte. Evaluación Final"
' End If
' Elseif doc.Estado(0)="NoProblema" Then
' est="Anulado"
' Else
' est=doc.Estado(0)
' End If
' Print "Procesando IRP: "+doc.NumeroIRPV(0)+" "+est
' .Cells(v4,4).Value=est
'
' Set hoy=New notesdatetime( Today )
' Set FC=Nothing
' If est="Cerrado" Or est="Anulado" Then
' Set FC=New notesdatetime(doc.FechaCierre(0))
' End If
' Set FA=Nothing
' Set FA=New notesdatetime(doc.FechaIdent(0))
'
' .Cells(v4,5).Value=Format(doc.FechaIdent(0),"dd/mmm/yyyy")
'
' If est="Cerrado" Then
' dif=FC.TIMEDIFFERENCE(FA)
' .Cells(v4,6).Value=Format(doc.fechacierre(0),"dd/mmm/yyyy")
' Else
' dif=hoy.TIMEDIFFERENCE(FA)
' .Cells(v4,6).Value=""
' End If
' If dif<>0 Then
' tiempo=Round(dif/60/60/24,0)
' Else
' tiempo=0
' End If
' sumtodas4=sumtodas4+tiempo
' .Cells(v4,7).Value=tiempo
' If est<>"Cerrado" Then
' .Cells(v4,8).Value=tiempo
' sumpendientes4=sumpendientes4+tiempo
' v4Pend=v4pend+1
' End If
' End With
' End If
' End If
'Fin hojas
Set doc= vis.getnextdocument(doc)
Wend
If v>1 Then works.cells(v+2,7)=sumtodas1 / (v-1)
If v1pend=0 Then
works.cells(v+2,8)=0
Else
works.cells(v+2,8)=sumpendientes1 / v1pend
End If
If v2>1 Then works2.cells(v2+2,7)=sumtodas2 / (v2-1)
If v2pend=0 Then
works2.cells(v2+2,8)=0
Else
works2.cells(v2+2,8)=sumpendientes2 / v2pend
End If
If v3>1 Then works3.cells(v3+2,7)=sumtodas3 / (v3-1)
If v3pend=0 Then
works3.cells(v3+2,8)=0
Else
works3.cells(v3+2,8)=sumpendientes3 / v3pend
End If
If v4>1 Then works4.cells(v4+2,7)=sumtodas4 / (v4-1)
If v4pend=0 Then
works4.cells(v4+2,8)=0
Else
works4.cells(v4+2,8)=sumpendientes4 / v4pend
End If
apli.Visible=True
Call works.Activate
End Sub
Sincronización Lotus Notes - OO
Re: Sincronización Lotus Notes - OO
Es posible controlar OpenOffice.org con Visual Basic, como en este vinculo. Cambié unas partes del código que tratan con Calc para ilustrar como se haría. El código que trata con Notes, se puede dejar como esta.
(Yo no uso Visual Basic. No se si usé Call y Set correctamente )
Al final del código hay lineas que asignan números a Celdas. Es necesario usar esta forma
En Calc, se asigna texto al “String” de la celda y se asignan números al “Value” de la celda.
(Yo no uso Visual Basic. No se si usé Call y Set correctamente )
Código: Seleccionar todo
Sub Click(Source As Button)
Dim db As notesdatabase
Dim ses As New NotesSession
Set db = ses.currentdatabase
Dim docP As notesdocument
Dim obj As Variant
Dim apli As Variant
cont=0
Set vis = db.getview("IND-QUEJA")
Set doc= vis.getfirstdocument
'Crear un documento de Calc y asignarlo a workb
Set oSM = CreateObject("com.sun.star.ServiceManager")
Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
Set workb = oDesk.loadComponentFromURL("private:factory/scalc", "_blank", 0, arg())
' añadir hojas al libro con los nombres apropiados
Count = workb.Sheets.Count
Call workb.Sheets.insertNewByName(“quejas2006”,Count)
Call workb.Sheets.insertNewByName(“quejas2007”,Count+1)
Call workb.Sheets.insertNewByName(“quejas2008”,Count+2)
'Call workb.Sheets.insertNewByName(“quejas2008”,Count+3)
'Asignar las hojas a works, works2, works3 y works4
Set works = workb.Sheets.getByIndex(Count)
Set works2 = workb.Sheets.getByIndex(Count+1)
Setworks3 = workb.Sheets.getByIndex(Count+2)
'Setworks4 = workb.Sheets.getByIndex(Count+3)
v=1
v2=1
v3=1
v4=1
v1pend=0
v2pend=0
v3pend=0
v4pend=0
sumpendientes1=0
sumpendientes2=0
sumpendientes3=0
sumpendientes4=0
sumtodas1=0
sumtodas2=0
sumtodas3=0
sumtodas4=0
With works
'Estas lineas ilustran como cambiar el resto del código
'.Cells(1,1).Value="Ca/MA" cambia a
.getCellByPosition(1,1).String = "Ca/MA"
'.Columns(1).ColumnWidth=6 cambia a
.Columns(1).Width = 2000 'medido en 1/100 mm
'.Cells(1,2).Value="Año apertura"
.getCellByPosition(1,2).String = "Año apertura"
Código: Seleccionar todo
If v>1 Then works.getCellByPosition(v+2,7).Value= sumtodas1 / (v-1)
If v1pend=0 Then
works.getcellByPosition(v+2,8).Value=0