Como modificar el orígen de un fichero Excel 2003 con conexión a datos externos de tipo .cub

Creado por Compettia Support Team, Modificado el Mar, 30 Sep a 1:46 P. M. por Compettia Support Team

Para cambiar el origen datos de un cubo en Excel 2003, necesitaremos usar esta macro:

Sub CambiaPathCubo2003()
On error goto Error

Dim oPivotTable As PivotTable
Dim sDataSource As String
Dim NewPath,OldPath As String
Dim oSheet As Worksheet

Set oSheet = ActiveWorkbook.Worksheets("Cube")

For Each oPivotTable In oSheet.PivotTables

If Not oPivotTable.PivotCache Is Nothing Then
On Error Resume Next
If Len(oPivotTable.PivotCache.Connection) <> 0 Then

sDataSource = Split(UCase(oPivotTable.PivotCache.Connection), UCase("Data Source="))(1)
OldPath = Split(UCase(sDataSource), UCase(".cub"))(0)
OldPath = OldPath & ".cub"
NewPath = "C:\RUTA\micubo.cub" ' =NUEVARUTA

oPivotTable.PivotCache.Connection = Application.Substitute(LCase(oPivotTable.PivotCache.Connection), LCase(OldPath), LCase(NewPath))

End If
End If
Next

Exit Sub

Error:
Msgbox "Se ha producido un error:" & Err.Description

End Sub

En cambio en entornos con Excel 2007 o Excel 2010 , si podremos llegar a las propiedades del rango y modificar el origen de datos. Basta ver artículo MS:

http://office.microsoft.com/es-es/excel-help/actualizar-datos-conectados-importados-HP010087045.aspx

¿Le ha sido útil este artículo?

¡Qué bien!

Gracias por sus comentarios

¡Sentimos mucho no haber sido de ayuda!

Gracias por sus comentarios

¡Háganos saber cómo podemos mejorar este artículo!

Seleccione al menos una de las razones
Se requiere la verificación del CAPTCHA.

Sus comentarios se han enviado

Agradecemos su esfuerzo e intentaremos corregir el artículo