
Thank you for posting your question in the Microsoft Q&A forum.
Regarding your issue, I wanted to let you know that my knowledge of Office Scripts is quite limited. In this Excel tag, we primarily focus on features and formulas, so I’m not able to provide much help with scripting-related questions. I also don’t have the environment or technical setup to test Office Scripts code directly.
However, I did come across this link Excel script for generating pivot tables without subtotals that discusses hiding subtotals, which might be relevant to your issue. It could be worth checking out to see if it helps.
If that doesn’t resolve your problem, I recommend posting your question directly to Stack Overflow under the Office Scripts tag. They have a dedicated community with deeper expertise in scripting and automation, and you’re likely to get more accurate and helpful responses there.
For more details, please refer to: Newest 'office-scripts' Questions - Stack Overflow
Disclaimer: Those links non-Microsoft website. The page appears to be providing accurate, safe information. Watch out for ads on the site that may advertise products frequently classified as a PUP (Potentially Unwanted Products). Thoroughly research any product advertised on the site before you decide to download and install it.
Once again, I truly apologize for having to redirect you to another community. I genuinely wish I could help more, but given my limited knowledge in this area, I wouldn’t want to risk giving you inaccurate advice. I hope you understand, and I really appreciate your patience.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.