Guys, is there any activity or vb code in UiPath that clears out disabled items in Microsoft word?
Basically, I am converting about 10k Word Documents to PDF. Somehow, since it is processing within the loop, some of the documents are disabled at particular point and I want to clear out those disabled items from Word document in order to convert them into PDF.
Hi @chilled_lad
As per my understanding, you want to delete the disabled items in the document and save before converting to PDF.
If so, please use the VB.NET code below to delete the disabled items and save the file.
Code:
Sub OpenDeleteAndSave()
Dim oWord As Object
Set oWord = CreateObject(“Word.Application”)
Dim oDoc As Object
Set oDoc = oWord.Documents.Open("document_FilePath")
Dim oShapes As Shapes
Set oShapes = oDoc.Shapes
For Each oShape In oShapes
If Not oShape.IsOLEObject And Not oShape.IsLinked Then
oShape.Delete
End If
Next
oDoc.Save
oDoc.Close
oWord.Quit
End Sub
I hope it will be helpful for you
1 Like
@Kaviyarasu_N Thank you for your time and effort! I’ll try working on it!