Share via

Remove Wordprocessing.SdtBlock don't work!

Filipe DELOUREIRO 1 Reputation point
2021-08-31T12:37:16.967+00:00

Hi,

I can't delete a block with OpenXML SDK

Dim sdtBlock As Wordprocessing.SdtBlock() = wordDoc.MainDocumentPart.Document.Body.Descendants(Of Wordprocessing.SdtBlock)().ToArray()
For Each sdt As Wordprocessing.SdtBlock In sdtBlock
sdt.Remove()
Next
wordDoc.MainDocumentPart.Document.Save()

And when loading the docx, the file has not changed!

Thanks

Microsoft 365 and Office | Development | Other
0 comments No comments

1 answer

Sort by: Most helpful
  1. Obaid Farooqi MSFT 786 Reputation points Microsoft Employee Moderator
    2021-08-31T22:02:10.567+00:00

    Hi @Filipe DELOUREIRO
    This tag (openspecs-office) is dedicated to supporting issues related to open specifications. You can find open specifications at https://learn.microsoft.com/en-us/openspecs/
    Your inquiry is not related to open specifications. I am removing tag openspecs-office and adding tag office-addins-dev for a better chance of getting an answer.

    Also you may want to check out the following resources:
    https://github.com/OfficeDev/Open-XML-SDK/issues
    https://stackoverflow.com/questions/tagged/openxml-sdk

    Regards,
    Obaid Farooqi - MSFT

    Was this answer helpful?

    0 comments No comments

Your answer

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