Hola grupo! les comento un poco, he hecho una macro en word (perdon que no
sea de excel, pero en el fondo es una funcion de VB la que tiene problemas)
para imprimir documentos largos, pero al hacer el debug correspondiente me
he dando cuenta de que nunca se ejecuta la sentencia FOR, o mejor dicho, se
evalúa y no se ejecuta su contenido. Alguien sabe por qué puede llegar a
pasar esto?
Aqui les transcribo el código:
Sub Impresion()
'
' Impresion Macro
' Macro recorded 28/11/2005 by Alejandro Garrammone
'
Dim tiempo As Date
Dim cant_rep As Integer
Dim cant_pag As Integer
Dim hora, min, seg As Integer
Dim tiempo_entre1 As Date
Dim tiempo_entre2 As Date
Dim flag As Byte
Dim inicio As Integer
Dim fin As Integer
Dim concat As String
Dim contador as integer
'inicio del cuerpo del programa
cant_pag = Selection.Information(wdNumberOfPagesInDocument)
cant_rep = cant_pag \ 240
'cant_rep + 1 es lo que tengo que tomar para el rango final
tiempo = Time()
hora = Hour(tiempo)
min = Minute(tiempo)
seg = Second(tiempo)
tiempo_entre1 = TimeSerial(hora, min + 15, 0)
tiempo_entre2 = TimeSerial(hora, min + 15, 59)
If cant_pag > 240 Then
For contador = 1 To can_rep Step 1 'ESTE ES EL FOR CON PROBLEMAS!
flag = 0
Do
If flag < 1 Then
fin = 240 * contador
inicio = fin - 239
concat = inicio & "-" & fin
Application.PrintOut FileName:="",
Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:=concat, PageType:=
_
wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True,
Background:= _
True, PrintToFile:=False, PrintZoomColumn:=0,
PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
flag = 1
End If
tiempo = Time()
Loop Until (tiempo > tiempo_entre1) Or (tiempo < tiempo_entre2)
tiempo = Time()
hora = Hour(tiempo)
min = Minute(tiempo)
seg = Second(tiempo)
tiempo_entre1 = TimeSerial(hora, min + 15, 0)
tiempo_entre2 = TimeSerial(hora, min + 15, 59)
Next contador
fin = contador * 240
inicio = fin - 239
fin = cant_pag
concat = inicio & "-" & fin
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:=concat, PageType:= _
wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True, Background:= _
True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
Else
inicio = 1
fin = cant_pag
concat = incio & "-" & fin
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:=concat, PageType:= _
wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True, Background:= _
True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
End If
End Sub
Leer las respuestas