ayuda para imprimir desde visual basic un archivo de excel
hice un empaquetado de un programa donde utilizo una base de datos, exporta los datos a una hoja de excel y la guarda, luego doy la orden de imprimir. esto sale bien cuando estoy logueado como administrador del equipo, pero cuando me logueo con otro usuario ke no es administrador sale error al momento de mandar imorimir el archivo, pueden decirme el por ke de este error solo cuando el usuario no es administrador del equipo. y si alguna solucion a esto por favor decirmela, aqui les muestro el codigo ke utilizo para hacer lo ya mencionado.
Private Sub cmdexportar_Click()
Dim xla As New Excel.Application
Dim xlb As New Excel.Workbook
Dim xls As New Excel.Worksheet
Dim xlr As Excel.Range
Dim fin As String
Dim ini As String
ini = Format(dtpini, \"dd-mmm-yy\")
fin = Format(dtpfin, \"dd-mmm-yy\")
Set xlb = xla.Workbooks.Add \\'asignar el libro
Set xls = xlb.Worksheets.Add \\'asignar la hoja
xls.Activate
With xls.PageSetup
.LeftMargin = Application.InchesToPoints(1.18110236220472)
.RightMargin = Application.InchesToPoints(1.18110236220472)
.TopMargin = Application.InchesToPoints(0.984251968503937)
.BottomMargin = Application.InchesToPoints(0.984251968503937)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
End With
xls.Cells.Font.Size = 7
xls.Cells.RowHeight = 15
xls.Cells(1, 2) = \"ALIANZA PARA EL CAMPO 2005\"
Set xlr = xls.Cells(1, 2)
xlr.Select
xlr.Font.Size = 8
xlr.Font.Bold = True
xls.Cells(2, 1) = \" COMITE ESTATAL DE SANIDAD VEGETAL DE GUANAJUATO A.C.\"
Set xlr = xls.Cells(2, 1)
xlr.Select
xlr.Font.Size = 8
xlr.Font.Bold = True
xls.Cells(4, 1) = \" PROGRAMA INOCUIDAD AGROALIMENTARIA\"
xls.Cells(5, 2) = \"PERIODO \" & ini & \" al \" & fin
xls.Cells(7, 1) = \"ACCIONES\"
Set xlr = xls.Cells(7, 1)
xlr.Select
xlr.ColumnWidth = 30
xlr.RowHeight = 22
xlr.Font.Size = 8
xlr.Font.Bold = True
xlr.VerticalAlignment = vbCenter
xlr.HorizontalAlignment = 3
xls.Cells(8, 1) = \"MUESTREO DE PRODUCTO Y ANALISIS\"
xls.Cells(9, 1) = \"DIAGNOSTICO Y AUDITORIAS\"
xls.Cells(12, 1) = \"PROTECCION TRABAJADOR AGRICOLA\"
xls.Cells(13, 1) = \"ASISTENCIA TECNICA\"
xls.Cells(15, 1) = \"CAPACITACION\"
xls.Cells(18, 1) = \"DIVULGACION\"
Set xlr = xls.Cells(7, 2)
xlr.Select
xlr.ColumnWidth = 5
Dim x As Integer
Dim y As Integer
y = 0
For x = 8 To 18
xls.Cells(x, 2) = lblmetas(y).Caption
y = y + 1
Next x
xls.Cells(7, 3) = \"METAS\"
Set xlr = xls.Cells(7, 3)
xlr.Select
xlr.ColumnWidth = 1
xlr.Font.Size = 8
xlr.Font.Bold = True
xlr.VerticalAlignment = vbCenter
xls.Cells(8, 4) = \"MUESTRAS\"
xls.Cells(9, 4) = \"DIAGNOSTICOS\"
xls.Cells(10, 4) = \"AUDITORIAS\"
xls.Cells(11, 4) = \"HECTAREAS\"
xls.Cells(12, 4) = \"KIT\\'S\"
xls.Cells(13, 4) = \"ASESORIAS\"
xls.Cells(14, 4) = \"HECTAREAS\"
xls.Cells(15, 4) = \"PERSONAS\"
xls.Cells(16, 4) = \"CURSOS\"
xls.Cells(17, 4) = \"PLATICAS\"
xls.Cells(18, 4) = \"EJEMPLARES\"
xls.Cells(7, 5) = \"REALIZADO EN PERIODO\"
Set xlr = xls.Cells(7, 5)
xlr.Select
xlr.ColumnWidth = 9
xlr.Font.Size = 8
xlr.Font.Bold = True
xlr.VerticalAlignment = 5
xls.Cells(7, 6) = \"ACUMULADO A LA FECHA\"
Set xlr = xls.Cells(7, 6)
xlr.Select
xlr.ColumnWidth = 10
xlr.Font.Size = 8
xlr.Font.Bold = True
xlr.VerticalAlignment = 5
xls.Cells(7, 7) = \"PORCIENTO DE AVANCE\"
Set xlr = xls.Cells(7, 7)
xlr.Select
xlr.ColumnWidth = 9
xlr.Font.Size = 8
xlr.Font.Bold = True
xlr.VerticalAlignment = 5
Dim colu As Integer
Dim fila As Integer
Dim i As Integer
fila = 8
colu = 5
For x = 1 To 11
For i = 1 To 3
xls.Cells(fila, colu) = mfgreporte.TextMatrix(x, i)
colu = colu + 1
Next i
colu = 5
fila = fila + 1
Next x
\\'imprimir archivo
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Static num As Integer
Dim archivo As String
num = num + 1
archivo = \"reporte\" & num & \".xls\"
xls.SaveAs (\"\\\\geomatica\\bdinocuidad\\misreportes\\\" & archivo)
xla.Quit
Private Sub cmdexportar_Click()
Dim xla As New Excel.Application
Dim xlb As New Excel.Workbook
Dim xls As New Excel.Worksheet
Dim xlr As Excel.Range
Dim fin As String
Dim ini As String
ini = Format(dtpini, \"dd-mmm-yy\")
fin = Format(dtpfin, \"dd-mmm-yy\")
Set xlb = xla.Workbooks.Add \\'asignar el libro
Set xls = xlb.Worksheets.Add \\'asignar la hoja
xls.Activate
With xls.PageSetup
.LeftMargin = Application.InchesToPoints(1.18110236220472)
.RightMargin = Application.InchesToPoints(1.18110236220472)
.TopMargin = Application.InchesToPoints(0.984251968503937)
.BottomMargin = Application.InchesToPoints(0.984251968503937)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
End With
xls.Cells.Font.Size = 7
xls.Cells.RowHeight = 15
xls.Cells(1, 2) = \"ALIANZA PARA EL CAMPO 2005\"
Set xlr = xls.Cells(1, 2)
xlr.Select
xlr.Font.Size = 8
xlr.Font.Bold = True
xls.Cells(2, 1) = \" COMITE ESTATAL DE SANIDAD VEGETAL DE GUANAJUATO A.C.\"
Set xlr = xls.Cells(2, 1)
xlr.Select
xlr.Font.Size = 8
xlr.Font.Bold = True
xls.Cells(4, 1) = \" PROGRAMA INOCUIDAD AGROALIMENTARIA\"
xls.Cells(5, 2) = \"PERIODO \" & ini & \" al \" & fin
xls.Cells(7, 1) = \"ACCIONES\"
Set xlr = xls.Cells(7, 1)
xlr.Select
xlr.ColumnWidth = 30
xlr.RowHeight = 22
xlr.Font.Size = 8
xlr.Font.Bold = True
xlr.VerticalAlignment = vbCenter
xlr.HorizontalAlignment = 3
xls.Cells(8, 1) = \"MUESTREO DE PRODUCTO Y ANALISIS\"
xls.Cells(9, 1) = \"DIAGNOSTICO Y AUDITORIAS\"
xls.Cells(12, 1) = \"PROTECCION TRABAJADOR AGRICOLA\"
xls.Cells(13, 1) = \"ASISTENCIA TECNICA\"
xls.Cells(15, 1) = \"CAPACITACION\"
xls.Cells(18, 1) = \"DIVULGACION\"
Set xlr = xls.Cells(7, 2)
xlr.Select
xlr.ColumnWidth = 5
Dim x As Integer
Dim y As Integer
y = 0
For x = 8 To 18
xls.Cells(x, 2) = lblmetas(y).Caption
y = y + 1
Next x
xls.Cells(7, 3) = \"METAS\"
Set xlr = xls.Cells(7, 3)
xlr.Select
xlr.ColumnWidth = 1
xlr.Font.Size = 8
xlr.Font.Bold = True
xlr.VerticalAlignment = vbCenter
xls.Cells(8, 4) = \"MUESTRAS\"
xls.Cells(9, 4) = \"DIAGNOSTICOS\"
xls.Cells(10, 4) = \"AUDITORIAS\"
xls.Cells(11, 4) = \"HECTAREAS\"
xls.Cells(12, 4) = \"KIT\\'S\"
xls.Cells(13, 4) = \"ASESORIAS\"
xls.Cells(14, 4) = \"HECTAREAS\"
xls.Cells(15, 4) = \"PERSONAS\"
xls.Cells(16, 4) = \"CURSOS\"
xls.Cells(17, 4) = \"PLATICAS\"
xls.Cells(18, 4) = \"EJEMPLARES\"
xls.Cells(7, 5) = \"REALIZADO EN PERIODO\"
Set xlr = xls.Cells(7, 5)
xlr.Select
xlr.ColumnWidth = 9
xlr.Font.Size = 8
xlr.Font.Bold = True
xlr.VerticalAlignment = 5
xls.Cells(7, 6) = \"ACUMULADO A LA FECHA\"
Set xlr = xls.Cells(7, 6)
xlr.Select
xlr.ColumnWidth = 10
xlr.Font.Size = 8
xlr.Font.Bold = True
xlr.VerticalAlignment = 5
xls.Cells(7, 7) = \"PORCIENTO DE AVANCE\"
Set xlr = xls.Cells(7, 7)
xlr.Select
xlr.ColumnWidth = 9
xlr.Font.Size = 8
xlr.Font.Bold = True
xlr.VerticalAlignment = 5
Dim colu As Integer
Dim fila As Integer
Dim i As Integer
fila = 8
colu = 5
For x = 1 To 11
For i = 1 To 3
xls.Cells(fila, colu) = mfgreporte.TextMatrix(x, i)
colu = colu + 1
Next i
colu = 5
fila = fila + 1
Next x
\\'imprimir archivo
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Static num As Integer
Dim archivo As String
num = num + 1
archivo = \"reporte\" & num & \".xls\"
xls.SaveAs (\"\\\\geomatica\\bdinocuidad\\misreportes\\\" & archivo)
xla.Quit
