JohnMDZ
New member
- Joined
- Nov 18, 2020
- Messages
- 1
- Reaction score
- 0
- Points
- 0
- Excel Version(s)
- Excel 2019
Hi,
I created a Excel file to combine different other Excel files in one Pivot-Table, I used Power Query for that. In sense of usability I created a button which updates all connections and Pivots in the file via vba. The button work well on my machine. In contrast to my colleagues machine, when he opens the file a Message Box with this translated text occure: "An error occurred when printing to PRINTER-NAME. Microsoft Excel could not print. This may be caused by the following: ..."
After he hits "ok". The file is working as expected. I used the following VBA-Code.
"Query 1" connects to a file, which contains paths to the files of interests. "Query 2" uses these paths to access the different files and combine them to one datasets. This makes it necessary to update "Query 1" first, and afterwards update "Query 2".
I have no idea, where this Error is coming from. The file is not designed to print anything and my colleagues didn't print that day. I would be glad, if someone could give me a hint on that.
Thanks
John
I created a Excel file to combine different other Excel files in one Pivot-Table, I used Power Query for that. In sense of usability I created a button which updates all connections and Pivots in the file via vba. The button work well on my machine. In contrast to my colleagues machine, when he opens the file a Message Box with this translated text occure: "An error occurred when printing to PRINTER-NAME. Microsoft Excel could not print. This may be caused by the following: ..."
After he hits "ok". The file is working as expected. I used the following VBA-Code.
Code:
ThisWorkbook.Connections("Query 1").Refresh
' wait until query 1 is done
Application.CalculateUntilAsyncQueriesDone
ThisWorkbook.Connections("Query 2").Refresh
' wait until query 2 is done
Application.CalculateUntilAsyncQueriesDone
' refresh all PivotTables
Dim PT As PivotTable
Dim sheet As Worksheet
For Each sheet In ThisWorkbook.Sheets
For Each PT In sheet.PivotTables
PT.RefreshTable
Next PT
Next sheet
"Query 1" connects to a file, which contains paths to the files of interests. "Query 2" uses these paths to access the different files and combine them to one datasets. This makes it necessary to update "Query 1" first, and afterwards update "Query 2".
I have no idea, where this Error is coming from. The file is not designed to print anything and my colleagues didn't print that day. I would be glad, if someone could give me a hint on that.
Thanks
John