private ApExcel As Excel.Application
private sub TrabajarExcel ()
Din Varo as long
' declaración de otras variables locales que utiliza el procedimiento
Set ApExcel = New Excel.Application
If Not (ApExcel Is Nothing) Then
' crear el resto de objetos que necesitamos....
' ... código
' .... código
' .... código
Call FormatearCasillas
Call CodigoMateriales(Varo)
' .... código
' .... código
' .... código
Else
Call MsgBox("Ocurrió algún propblema al intentar crear la instancia de Excel..." & vbCrLf & "Has agregado una referencia al proyecto ?... está instalado Excel ?", vbCritical + vbOKOnly, "No se puede continuar...")
End Ifend Sub
Private Sub FormatearCasillas()
ApExcel.Range("A16:N17").Borders(xlEdgeBottom).LineStyle = xlContinuous
ApExcel.Range("A16:N17").Borders(xlEdgeBottom).Weight = xlThin
ApExcel.Range("A16:N17").Borders(xlEdgeBottom).ColorIndex = xlAutomatic
ApExcel.Range("A16:N17").Borders(xlEdgeRight).LineStyle = xlContinuous
ApExcel.Range("A16:N17").Borders(xlEdgeRight).Weight = xlThin
ApExcel.Range("A16:N17").Borders(xlEdgeRight).ColorIndex = xlAutomatic
ApExcel.Range("A16:N17").Borders(xlInsideVertical).LineStyle = xlContinuous
ApExcel.Range("A16:N17").Borders(xlInsideVertical).Weight = xlThin
ApExcel.Range("A16:N17").Borders(xlInsideVertical).ColorIndex = xlAutomatic
ApExcel.Range("A16:N17").Borders(xlInsideHorizontal).LineStyle = xlContinuous
ApExcel.Range("A16:N17").Borders(xlInsideHorizontal).Weight = xlThin
ApExcel.Range("A16:N17").Borders(xlInsideHorizontal).ColorIndex = xlAutomatic
ApExcel.Range("A16:N17").Borders(xlDiagonalDown).LineStyle = xlNone
ApExcel.Range("A16:N17").Borders(xlDiagonalUp).LineStyle = xlNone
ApExcel.Range("A16:N17").Borders(xlEdgeLeft).LineStyle = xlContinuous
ApExcel.Range("A16:N17").Borders(xlEdgeLeft).Weight = xlMedium
ApExcel.Range("A16:N17").Borders(xlEdgeLeft).ColorIndex = xlAutomatic
ApExcel.Range("A16:N17").Borders(xlEdgeTop).LineStyle = xlContinuous
ApExcel.Range("A16:N17").Borders(xlEdgeTop).Weight = xlMedium
ApExcel.Range("A16:N17").Borders(xlEdgeTop).ColorIndex = xlAutomatic
ApExcel.Range("A16:N17").Borders(xlEdgeBottom).LineStyle = xlContinuous
ApExcel.Range("A16:N17").Borders(xlEdgeBottom).Weight = xlMedium
ApExcel.Range("A16:N17").Borders(xlEdgeBottom).ColorIndex = xlAutomatic
ApExcel.Range("A16:N17").Borders(xlEdgeRight).LineStyle = xlContinuous
ApExcel.Range("A16:N17").Borders(xlEdgeRight).Weight = xlMedium
ApExcel.Range("A16:N17").Borders(xlEdgeRight).ColorIndex = xlAutomatic
ApExcel.Range("A16:N17").Borders(xlInsideVertical).LineStyle = xlContinuous
ApExcel.Range("A16:N17").Borders(xlInsideVertical).Weight = xlThin
ApExcel.Range("A16:N17").Borders(xlInsideVertical).ColorIndex = xlAutomatic
ApExcel.Range("A16:N17").Borders(xlInsideHorizontal).LineStyle = xlContinuous
ApExcel.Range("A16:N17").Borders(xlInsideHorizontal).Weight = xlThin
ApExcel.Range("A16:N17").Borders(xlInsideHorizontal).ColorIndex = xlAutomatic
ApExcel.Range("A1:F17").Font.Bold = True
End Sub
'CODIGO DE MATERIALES
Private Sub CodigoMateriales(ByVal Varo As Long)
Dim VarSumatoria As Double
Dim VarSumatoria2 As Double
Dim indi As String
Dim i As Long, l As Long, S As Long, Z As Long, ex As Long
Dim cor As Long, Valorcorte As Long, VarStop As Long, VarCantCortes As Long
Dim NumeroCorte2 As Long, VarIdCorte As Long
i = 1
VarSumatoria = 0
VarSumatoria2 = 0
VarStop = 0
VarCantCortes = 0
NumeroCorte2 = FrmCrearCotizacion.ObtenerNumero(TxtDescripcionCorte6)
NumeroCorte2 = NumeroCorte2 - 1
VarIdCorte1 = TxtIdCorte
Varo = 0
l = 7
S = 8
Z = 18
ex = 1
For cor = 1 To Valorcorte
indi = cor
Limpiavec
Z = 18
Adodc6.Recordset.MoveFirst
Do While Not Adodc6.Recordset.EOF
If TxtIdCotizacion6 = FrmCrearCotizacion.TxtIdCotizacion Then
If ItenExiste6 = False Then
VectorItemAvance(Varo) = TxtItem6
ApExcel.Cells(Varo + 18, 1).Formula = Val(TxtItem6) 'TxtItem6
ApExcel.Cells(Varo + 18, 2).Formula = TxtNOmbreItem6 'TxtNOmbreItem6
ApExcel.Cells(Varo + 18, 3).Formula = TxtUnidadItem6 'TxtUnidadItem6
ApExcel.Cells(Varo + 18, 4).Formula = TxtCantidadPresupuestada6 'cant
ApExcel.Cells(Varo + 18, 5).Formula = Val(TxtVrInitItem6) 'Precio unitario
ApExcel.Cells(Varo + 18, 6).Formula = TxtVrInitItem6 * TxtCantidadPresupuestada6 'Vr total
If indi = ex Then
ApExcel.Cells(17, l).Formula = "CANT"
ApExcel.Cells(17, S).Formula = "Vr,TOTAL"
ApExcel.Cells(16, l).Formula = "AVANCE " + indi
'Unir Celdas
ApExcel.Range("G16:N16").HorizontalAlignment = xlCenter
ApExcel.Range("G16:N16").VerticalAlignment = xlBottom
ApExcel.Range("G16:N16").WrapText = False
ApExcel.Range("G16:N16").Orientation = 0
ApExcel.Range("G16:N16").AddIndent = False
ApExcel.Range("G16:N16").IndentLevel = 0
ApExcel.Range("G16:N16").ShrinkToFit = False
ApExcel.Range("G16:N16").ReadingOrder = xlContext
ApExcel.Range("G16:N16").MergeCells = False
ApExcel.Range("G16:H16").Merge
ApExcel.Range("I16:J16").Merge
ApExcel.Range("K16:L16").Merge
ApExcel.Range("M16:N16").Merge
ex = ex + 1
End If
Do While Not Adodc1.Recordset.EOF
If TxtItem6 = TxtItem1 And TxtIdCotizacion1 = TxtIdCotizacion6 And TxtDescripcionCorte1 = "Corte No " + indi Then
If FrmCrearCotizacion.FechaMayor(TxtFecIngresoCant1, TxtFechaInicio1) = True Then
If FrmCrearCotizacion.FechaMayor(TxtFechaFin1, TxtFecIngresoCant1) = True Then
VarSumatoria = TxtCantidadEjecutada1 + VarSumatoria 'cant eje
End If
End If
End If
Adodc1.Recordset.MoveNext
Loop
Adodc1.Recordset.MoveFirst
ApExcel.Cells(Varo + Z, l).Formula = VarSumatoria 'cant eje
ApExcel.Cells(Varo + Z, S).Formula = TxtVrInitItem6 * VarSumatoria 'Precio unitario
SUMATOAVA = TxtVrInitItem6 * VarSumatoria
Varo = Varo + 1
End If
End If
Adodc6.Recordset.MoveNext
VarSumatoria = 0
Loop
Adodc6.Recordset.MoveFirst
l = l + 2
S = S + 2
Z = Z + 1
Next cor
End Sub