Skip to main content

Notifications

Community site session details

Community site session details

Session Id : IZC2baQRwGItEvrGo8nnnS
Power Automate - General Discussion
Unanswered

Converting Macro Enabled Word doc (.docm) file to PDF

Like (0) ShareShare
ReportReport
Posted on 2 Nov 2021 20:21:57 by 2

Hello,

 

I have been able to convert regular word (.doc and .docx) file to pdf using the onedrive for Business - convert file option. However, I am running into issue with converting a docm file. Looking through following documentation, the file format is not supported. However, I was wondering if anyone has found a workaround.

 

https://docs.microsoft.com/en-us/connectors/onedriveforbusiness/#convert-file-(preview)

https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get_content_format?view=odsp-graph-online

 

Thank You

Categories:
  • VJR Profile Picture
    7,635 on 04 Nov 2021 at 06:11:55
    Re: Converting Macro Enabled Word doc (.docm) file to PDF

    Hi @powerautomate5 

     

    I was able to successfully run both the options.

    But my files were very simple ones with one liner text contained in them.

     

    In option 1, I am not using the Convert file. Just "Get file content" and "Create file" were enough to create the docx file.

     

    In option 2, I have simply used one action "Copy file using Path" and in the Destination File Path gave Test.docx

     

    Both the options gave me docx files.

    However, there is a caveat to both these options.

    They both did create the docx files on OneDrive. I was able to open and see the contents when opened in Word online itself. But the contents were not visible when opened in the desktop app.

     

    You can try them out and see if that is workable for you.

    These are not actual conversion methods so not recommended options.

    Just thought of giving some inputs since there is nothing in-built as of now.

     

  • powerautomate5 Profile Picture
    2 on 03 Nov 2021 at 13:54:07
    Re: Converting Macro Enabled Word doc (.docm) file to PDF

    Option 1:

    powerautomate5_0-1635946625316.png

     

    Error:

    Error from Office Service. Url=https://wordcs.officeapps.live.com/document/export/pdf HttpCode=UnsupportedMediaType cert=subject:;thumbprint: ResponseHeaders=X-ErrorCode: WordDocumentHasMetroMEContentNonMetroMEExtension
    X-ClientCorrelationId: 4e619cbb-47f2-488b-b7e0-1d9090ac69a4
    X-ServiceCorrelationId: 4e619cbb-47f2-488b-b7e0-1d9090ac69a4
    X-ErrorCategory: NotSupported
    X-IsRetriable: False
    X-ConversionTimeInMs: 156.2541
    X-FileDownloadTimeInMs: 531.2618
    Cache-Control: private
    Date: Wed, 03 Nov 2021 13:36:13 GMT
    Server: Microsoft-IIS/10.0
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET

     

    I get the same error with option 2.

     

    I have also tried converting the file content to base64 and changing the content type to word, and see if it would lose the macros. No dice. 

    powerautomate5_1-1635947600759.png

     

    Error: 

    Error from Office Service. Url=https://wordcs.officeapps.live.com/document/export/pdf HttpCode=UnsupportedMediaType cert=subject:;thumbprint: ResponseHeaders=X-ErrorCode: WordDocumentHasMetroMEContentNonMetroMEExtension
    X-ClientCorrelationId: cfc50925-bf6c-4b05-ad0e-eefad42f065f
    X-ServiceCorrelationId: cfc50925-bf6c-4b05-ad0e-eefad42f065f
    X-ErrorCategory: NotSupported
    X-IsRetriable: False
    X-ConversionTimeInMs: 156.2542
    X-FileDownloadTimeInMs: 453.1315
    Cache-Control: private
    Date: Wed, 03 Nov 2021 13:53:38 GMT
    Server: Microsoft-IIS/10.0
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
  • VJR Profile Picture
    7,635 on 03 Nov 2021 at 04:03:05
    Re: Converting Macro Enabled Word doc (.docm) file to PDF

    Hi @powerautomate5 

     

    Haven't tried it but just some ideas

    Using OneDrive for business for both these options-

     

    option 1: 

    - Get file content (of the docm file)

    - Create file (using the above content). Give Test.docx in the file name

     

    option 2: 

    - Copy file using Path

    in the Destination File Path give Test.docx

    If the docx comes out to be correct then you already have got it to converting to pdf.

     

    Make sure to make backup copies before trying this as it may cause possible data loss.

    Open the new docx file in the browser as well as on the desktop Word app to see if everything looks fine.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,763 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading started