I've unfortunately run into a new problem with this solution. I have a workbook that needs to have subtotals added to the QueryTable range. I added the last two lines (the Range and Subtotal functions) to the original VB macro in the spreadsheet:
This works fine when I open the workbook manually. The CSV data refreshes and the subtotals get populated correctly. I can then manually do a SaveAs PDF and the PDF is written correctly with the subtotals included.
The problem comes in when I use my VB Script automation program (see original post) which opens the workbook, refreshes the QueryTable and does a SaveAs PDF. It gets through the call to RefreshAll and then brings up a Visual Basic error dialog box with the following error:
If I click the Debug button on the error it brings me to the Selection.Subtotal line in the VB macro in the workbook.
Anyone have any thoughts about what's going on here? I've been tearing my hair out with this for a couple of days now.
Thanks again for your help.
Bookmarks