Hybrid Worker Hangs on Excel Macro Exporting to PDF

Teele, Stone 0 Reputation points
2023-09-07T18:10:21.49+00:00

We have an Excel macro that saves each worksheet down as a PDF, HTML, and XLS. When I run the Excel file locally on the server, the macro works fine. But when I run it via a runbook, I can see a tmp file is created, but not a PDF file and it just hangs. Exporting to HTML and xls work fine from Azure runbooks when the PDF code is commented out.

Has anyone experienced this?

Configuration:

  1. Extension based worker with Azure Arc (On-premise)
  2. Excel 2013
  3. Hybrid worker credentials set to a domain service account
  4. Macro runs on-open
  5. VBA code it hangs on:
ActiveWorkbook.ActiveSheet.ExportAsFixedFormat _
                Type:=xlTypePDF, _
                Filename:="C:\myFolder\" & ActiveWorkbook.ActiveSheet.Name & ".pdf", _
                Quality:=xlQualityMinimum, _
                IncludeDocProperties:=True, _
                IgnorePrintAreas:=False, _
                OpenAfterPublish:=False
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,245 questions
{count} votes

1 answer

Sort by: Most helpful
  1. tbgangav-MSFT 10,416 Reputation points
    2023-09-13T08:46:31.4266667+00:00

    Hi @Teele, Stone ,

    The issue you are experiencing with the Excel macro hanging when exporting to PDF via a runbook may be related to the fact that the runbook is running on a hybrid worker. In general, there are limitations to running Excel workbooks in a user interactive session on compute nodes, which may be causing the issue. Additionally, heavy Excel workloads can run slowly in multi-session environments due to default thread limitations.

    To troubleshoot the issue, you may want to try

    • modifying the macro to export to PDF in a different way, such as using a different library or API.
    • splitting the runbook into different stages, each exporting one worksheet to PDF. This can help identify if there is a specific worksheet or part of your Excel file causing the issue.
    • adding logging statements to your VBA code to record progress and intermediate steps. This can help identify where the script is hanging.
    • using the built-in Run As account in Azure Automation if possible, instead of using a domain service account. Ensure that this account has the necessary permissions on the Hybrid Worker and the target file system.

    If these troubleshooting steps doesn't help to solve the issue, then you might have to raise a support ticket and reach out to support team to understand the reason for the issue by checking the runbook job related backend logs or traces.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.