开发者

Excel pivot refresh, save and close in Access VBA code

开发者 https://www.devze.com 2022-12-16 17:15 出处:网络
I am using the following code to refresh Excel pivot tables from an Access application.What is the best way to save and close the Excel app after the pivots refresh?In my last attempt the code was try

I am using the following code to refresh Excel pivot tables from an Access application. What is the best way to save and close the Excel app after the pivots refresh? In my last attempt the code was trying to save and close before the pivots had refreshed.

Private Sub Command161_Click()   
  Dim objXL As Object, x

  On Error Resume Next
  Set objXL = CreateObject("Excel.开发者_JAVA技巧Application")
  With objXL.Application
    .Visible = True
    'Open the Workbook
    .Workbooks.Open "myfilepath.xls"
    'Refresh Pivots
    x = .ActiveWorkbook.RefreshAll
  End With    
  Set objXL = Nothing
End Sub


Set the pivottable.pivotcache.backgroundquery property to False for synchronous updates.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号