Hi,
I read many posts on the internet concerning the VBA error mentionned in the subject line, but none gave me a solution.
I am producing a series of graphs in excel, from access (office 2007). The first time, it runs perfectly well. When I run it a second time, I get:
"The remote server machine does not exist or is navailable" on a specific statement. If I close Access and restart the program, it runs well the first time, but always give me the error the second time.
Here are the relevant statements:
........
TWait = Time
TWait = DateAdd("s", 2, TWait)
Do Until TNow >= TWait
TNow = Time
Loop
Set xlObj = CreateObject("excel.application")
xlObj.Workbooks.Open MyDashboard
With xlObj
.Sheets("Dashboard 1 of 4").Select
.Range("A1").Select
.ActiveCell.FormulaR1C1 = Me.Category & " " & Me.Base
.Sheets("Dashboard 2 of 4").Select
.Range("A1").Select
.ActiveCell.FormulaR1C1 = Me.Category & " " & Me.Base
.Sheets("Dashboard 3 of 4").Select
.Range("A1").Select
.ActiveCell.FormulaR1C1 = Me.Category & " " & Me.Base
.Sheets("Dashboard 4 of 4").Select
.Range("A1").Select
.ActiveCell.FormulaR1C1 = Me.Category & " " & Me.Base
End With
'************************************************************************************************************
'Dashboard Creation
'************************************************************************************************************
MyTable1.Index = "PrimaryKey"
MyTable1.Seek "=", MyParamKey
Do Until MyTable1.EOF
'************************************************************************************
'* Getting tblVBAParams Parameters
'************************************************************************************
ReportID = MyTable1![ReportID]
ReportID_Pivot = Trim(ReportID & "_Pivot")
MyReportNo = MyTable1![MyReportNo]
Select Case MyReportNo
Case "101A", "102A"
GoTo MyNEXT
End Select
Col1Orientation = MyTable1![Col1Orientation]
Col2Orientation = MyTable1![Col2Orientation]
MyPageField = MyTable1![MyPageField]
MySecondPageField = MyTable1![MySecondPageField]
MyThirdPageField = MyTable1![MyThirdPageField]
MyRowField = MyTable1![MyRowField]
RepChartTitle = MyTable1![RepChartTitle]
If IsNull(MyTable1![RepAxisTitle]) Then
Else
RepAxisTitle = MyTable1![RepAxisTitle]
RepChartAxisStyle = MyTable1![RepChartAxisStyle]
End If
If IsNull(MyTable1![RepAxisSecondaryTitle]) Then
Else
RepAxisSecondaryTitle = MyTable1![RepAxisSecondaryTitle]
RepAxisSecondarySeries = MyTable1![RepAxisSecondarySeries]
RepSecondaryColorIndex = MyTable1![RepSecondaryColorIndex]
RepChartSecondaryAxisValueStyle = MyTable1![RepChartSecondaryAxisValueStyle]
End If
RepAxisPrimSerThous = MyTable1![RepAxisPrimSerThous]
RepAxisSecSerThous = MyTable1![RepAxisSecSerThous]
RepColorIndex = MyTable1![RepColorIndex]
RepChartTitleSize = MyTable1![RepChartTitleSize]
ChartObjectNo = MyTable1![ChartObjectNo]
DashboardSheet = MyTable1![DashboardSheet]
LegendTop = MyTable1![LegendTop]
PivotDest = Trim(ReportID_Pivot & "!R3C1")
MyPivotSheetName = MyTable1![MyPivotSheetName]
PivotName = Trim(ReportID & "!" & ReportID_Pivot)
MyTargetChartPos = MyTable1![MyTargetChartPos]
MyScaleWidth = MyTable1![MyScaleWidth]
MyScaleHeight = MyTable1![MyScaleHeight]
NbOfCols = MyTable1![NbOfCols]
MyXaxis = MyTable1![MyXaxis]
WeekDateInTitle = MyTable1![WeekDateInTitle]
'************************************************************************************
'Columns Titles, Pivot Calculation (xlSum or xlMax), Columns Types (xlLine or xlBar)
'************************************************************************************
Col1 = MyTable1![Col1]
Col2 = MyTable1![Col2]
Col3 = MyTable1![Col3]
Col4 = MyTable1![Col4]
Col5 = MyTable1![Col5]
Col6 = MyTable1![Col6]
Col7 = MyTable1![Col7]
Col8 = MyTable1![Col8]
Col9 = MyTable1![Col9]
Col1SM = MyTable1![Col1SM]
Col2SM = MyTable1![Col2SM]
Col3SM = MyTable1![Col3SM]
Col4SM = MyTable1![Col4SM]
Col5SM = MyTable1![Col5SM]
Col6SM = MyTable1![Col6SM]
Col7SM = MyTable1![Col7SM]
Col8SM = MyTable1![Col8SM]
Col9SM = MyTable1![Col9SM]
ColType(1) = MyTable1![Col1Type]
ColType(2) = MyTable1![Col2Type]
ColType(3) = MyTable1![Col3Type]
ColType(4) = MyTable1![Col4Type]
ColType(5) = MyTable1![Col5Type]
ColType(6) = MyTable1![Col6Type]
ColType(7) = MyTable1![Col7Type]
ColType(8) = MyTable1![Col8Type]
ColType(9) = MyTable1![Col9Type]
With xlObj
'.Application.ScreenUpdating = False
'.Visible = True
.Sheets(ReportID).Select
.Range("A1", ActiveCell.SpecialCells(xlLastCell)).Select
.ActiveWorkbook.Names.Add Name:=ReportID_Pivot, RefersToR1C1:=Selection
.Sheets.Add.Name = ReportID_Pivot
.ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
PivotName, Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:=PivotDest, TableName:=MyPivotSheetName, DefaultVersion _
:=xlPivotTableVersion12
etc...................
The error happens on the following statement:
.Range("A1", ActiveCell.SpecialCells(xlLastCell)).Select
Any idea?
Thank you.
I read many posts on the internet concerning the VBA error mentionned in the subject line, but none gave me a solution.
I am producing a series of graphs in excel, from access (office 2007). The first time, it runs perfectly well. When I run it a second time, I get:
"The remote server machine does not exist or is navailable" on a specific statement. If I close Access and restart the program, it runs well the first time, but always give me the error the second time.
Here are the relevant statements:
........
TWait = Time
TWait = DateAdd("s", 2, TWait)
Do Until TNow >= TWait
TNow = Time
Loop
Set xlObj = CreateObject("excel.application")
xlObj.Workbooks.Open MyDashboard
With xlObj
.Sheets("Dashboard 1 of 4").Select
.Range("A1").Select
.ActiveCell.FormulaR1C1 = Me.Category & " " & Me.Base
.Sheets("Dashboard 2 of 4").Select
.Range("A1").Select
.ActiveCell.FormulaR1C1 = Me.Category & " " & Me.Base
.Sheets("Dashboard 3 of 4").Select
.Range("A1").Select
.ActiveCell.FormulaR1C1 = Me.Category & " " & Me.Base
.Sheets("Dashboard 4 of 4").Select
.Range("A1").Select
.ActiveCell.FormulaR1C1 = Me.Category & " " & Me.Base
End With
'************************************************************************************************************
'Dashboard Creation
'************************************************************************************************************
MyTable1.Index = "PrimaryKey"
MyTable1.Seek "=", MyParamKey
Do Until MyTable1.EOF
'************************************************************************************
'* Getting tblVBAParams Parameters
'************************************************************************************
ReportID = MyTable1![ReportID]
ReportID_Pivot = Trim(ReportID & "_Pivot")
MyReportNo = MyTable1![MyReportNo]
Select Case MyReportNo
Case "101A", "102A"
GoTo MyNEXT
End Select
Col1Orientation = MyTable1![Col1Orientation]
Col2Orientation = MyTable1![Col2Orientation]
MyPageField = MyTable1![MyPageField]
MySecondPageField = MyTable1![MySecondPageField]
MyThirdPageField = MyTable1![MyThirdPageField]
MyRowField = MyTable1![MyRowField]
RepChartTitle = MyTable1![RepChartTitle]
If IsNull(MyTable1![RepAxisTitle]) Then
Else
RepAxisTitle = MyTable1![RepAxisTitle]
RepChartAxisStyle = MyTable1![RepChartAxisStyle]
End If
If IsNull(MyTable1![RepAxisSecondaryTitle]) Then
Else
RepAxisSecondaryTitle = MyTable1![RepAxisSecondaryTitle]
RepAxisSecondarySeries = MyTable1![RepAxisSecondarySeries]
RepSecondaryColorIndex = MyTable1![RepSecondaryColorIndex]
RepChartSecondaryAxisValueStyle = MyTable1![RepChartSecondaryAxisValueStyle]
End If
RepAxisPrimSerThous = MyTable1![RepAxisPrimSerThous]
RepAxisSecSerThous = MyTable1![RepAxisSecSerThous]
RepColorIndex = MyTable1![RepColorIndex]
RepChartTitleSize = MyTable1![RepChartTitleSize]
ChartObjectNo = MyTable1![ChartObjectNo]
DashboardSheet = MyTable1![DashboardSheet]
LegendTop = MyTable1![LegendTop]
PivotDest = Trim(ReportID_Pivot & "!R3C1")
MyPivotSheetName = MyTable1![MyPivotSheetName]
PivotName = Trim(ReportID & "!" & ReportID_Pivot)
MyTargetChartPos = MyTable1![MyTargetChartPos]
MyScaleWidth = MyTable1![MyScaleWidth]
MyScaleHeight = MyTable1![MyScaleHeight]
NbOfCols = MyTable1![NbOfCols]
MyXaxis = MyTable1![MyXaxis]
WeekDateInTitle = MyTable1![WeekDateInTitle]
'************************************************************************************
'Columns Titles, Pivot Calculation (xlSum or xlMax), Columns Types (xlLine or xlBar)
'************************************************************************************
Col1 = MyTable1![Col1]
Col2 = MyTable1![Col2]
Col3 = MyTable1![Col3]
Col4 = MyTable1![Col4]
Col5 = MyTable1![Col5]
Col6 = MyTable1![Col6]
Col7 = MyTable1![Col7]
Col8 = MyTable1![Col8]
Col9 = MyTable1![Col9]
Col1SM = MyTable1![Col1SM]
Col2SM = MyTable1![Col2SM]
Col3SM = MyTable1![Col3SM]
Col4SM = MyTable1![Col4SM]
Col5SM = MyTable1![Col5SM]
Col6SM = MyTable1![Col6SM]
Col7SM = MyTable1![Col7SM]
Col8SM = MyTable1![Col8SM]
Col9SM = MyTable1![Col9SM]
ColType(1) = MyTable1![Col1Type]
ColType(2) = MyTable1![Col2Type]
ColType(3) = MyTable1![Col3Type]
ColType(4) = MyTable1![Col4Type]
ColType(5) = MyTable1![Col5Type]
ColType(6) = MyTable1![Col6Type]
ColType(7) = MyTable1![Col7Type]
ColType(8) = MyTable1![Col8Type]
ColType(9) = MyTable1![Col9Type]
With xlObj
'.Application.ScreenUpdating = False
'.Visible = True
.Sheets(ReportID).Select
.Range("A1", ActiveCell.SpecialCells(xlLastCell)).Select
.ActiveWorkbook.Names.Add Name:=ReportID_Pivot, RefersToR1C1:=Selection
.Sheets.Add.Name = ReportID_Pivot
.ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
PivotName, Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:=PivotDest, TableName:=MyPivotSheetName, DefaultVersion _
:=xlPivotTableVersion12
etc...................
The error happens on the following statement:
.Range("A1", ActiveCell.SpecialCells(xlLastCell)).Select
Any idea?
Thank you.