Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/04/2010, 09:18
Avatar de agressor
agressor
 
Fecha de Ingreso: noviembre-2007
Ubicación: Knocking the Death Door..
Mensajes: 368
Antigüedad: 16 años, 5 meses
Puntos: 3
Pregunta Error en Hoja Nueva

Buenos Dias Foreros!

Mi situacion es la siguiente tengo un codigo en Visual basic for application donde creo un archivo de excel a partir de un sql y luego de ese SQL creo un archivo de excel, un tabla pivoteada y una grafica pivoteada funciona bien cada 2 veces.

Run Time Error '91'

"Object Variables or With Block variable no set"

Este es mi codigo

Dim objexcel As Object
Dim objwbk As Workbook
Dim objwsh_a As Worksheet
Dim objwsh_b As Worksheet
Dim objwsh_c As Worksheet
Const RadThpyDir As String = dir
Const RadWDat_b = "Bol"
Const PVTSht = "Pivot_RTherapy_Wgt"
Dim RtherapyFle As String
RtherapyFle = "Comparativa Prioridades" & Format(Now(), "DDMMMYY") & "_" & Format(Now(), "hhmm") & ".xls"

CurrentDb.QueryDefs("Bol").Sql = sql

DoCmd.OutputTo acOutputQuery, "Bol", acFormatXLS, RadThpyDir & "\" & RtherapyFle

Set objexcel = CreateObject("Excel.Application")
objexcel.Visible = True
Set objwbk = objexcel.Workbooks.Open(RadThpyDir & "\" & RtherapyFle)
Set objwsh_b = objwbk.Worksheets(RadWDat_b)

DoCmd.SetWarnings False

ActiveWorkbook.Sheets.Add <- En esta linea me muestra el error y no se por que??
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDa tabase, SourceData:= _
"Bol!R1C1:R15C3", Version:=xlPivotTableVersion10). _
CreatePivotTable TableDestination:="Sheet1!R1C1", TableName:="PivotTable1" _
, DefaultVersion:=xlPivotTableVersion10
Sheets("Sheet1").Select
Cells(1, 1).Select


Gracias de igual manera.!
__________________
Somos lo que nosotros queremos ni mas ni menos..
No hay dia mas perdido que aquel en que no hemos reido..
La vida es tal y como debe ser...
Nadie vivira por ti...