What is activity in UiPath

Category: code

In a customer project, the desire to automate slides based on key figures in Microsoft's Powerpoint software arose. The 2019 version of the RPA software UiPath is used in the aforementioned environment. While the integration of Microsoft products is sure to improve in the future. In this environment one often has to fall back on the rather unreliable surface automation.

In the project in question, it was possible to access the system interfaces directly from Powerpoint. This can be accessed via short scripts in the languages ​​Visual Basic (VB) or C #. These little scripts can be wonderfully integrated into UiPath. Note: There are some third-party packages that allow you to edit PowerPoint slides. Unfortunately, I was not enthusiastic about the reliability and functionality of these packages.

In this article, we'll explore how to iterate through the slides in a presentation and identify those that have been hidden. In the next step the found foils should be removed. This is relevant in the aforementioned customer project, as the hidden slides should not be published.

How do you implement the requirement in VB?

The following code is sufficient to implement the requirement:

The basis of the processing is the Powerpoint software, which has the command CreateObject ("Powerpoint.Application") is started. After that, the program can be operated in the foreground or hidden.

This is done via the test on objPPT.Visible = True .
A Powerpoint presentation will then be loaded. In this case, the presentation is saved in: C: \ Temp \ Presentation.pptx in the variable objPresentationloaded, in which the individual slides then via:

For x = objPresentation.Slides.Count to 1 Step -1

Iterated from the last slide to the first.

When this slide is hidden (.SlideShowTransition.Hidden = True), then it will be deleted. It is important in this case that the slides are iterated from the last to the first, otherwise the deletion process can lead to a problem.

How do you integrate Visual Basic with UiPath?

The integration into a UiPath process is then very easy to implement. The VB code described above is integrated into a script file for this purpose. This usually has the file extension .vbs for Visual Basic Script. After that, the code can be called quite easily via the UiPath activity: "Invoke VBScript". That was it. No parameters are passed in the code section described above, but this would be possible with this activity as well as processing an output result.

In the meantime, the powerpoint generation using UiPath automation has been completely implemented for my customer. This now includes significantly more functions than the deletion of foils described here. If you are also interested in this, please leave me a comment.

I have summarized the discussed minimal example for you in the following archive: Code