Print excel sheet to pdf - Microsoft 365

I am having trouble finding a stable selector when printing excel sheet to pdf. I previously was able to use both a click image and a click button task to perform it. However with the new Microsoft 365 update I have been unable to perform. Has anybody run into a similar issue, or have an alternative suggestion?

1 Like

@cdoughty Welcome to the community!

When you say print what do you mean? Print to a printer? Write to a PDF? Save as a PDF?

Hi @cdoughty
Using hotkey doesn’t help you?

@Jarzzz, yes print to pdf and save. The sheet is a template that runs data out of a matrix, and will be done a couple hundred times.

@KMota, so that is another curious issue I’m running into. I use hotkey to prompt the print itself, and that works fine. However once the print window is brought up, sending hotkey to hit “enter” on the window is not working either.

@cdoughty
I also faced a problem similar to using the shortcut key enter, had to change to click, was not going at all

@cdoughty Try the below.

> Send Hotkey - Alt & FP
> Send Hoteky - I
> Click - Microsoft Print to PDF
> Click - Print
> Type - "File name"
> Click - Save

> Selector for the Microsoft Print to PDF below. Change title = 'Book1'

> <wnd app='excel.exe' title='Book1 - Excel' />
> <ctrl name='Microsoft Print to PDF' role='list item' />
1 Like

@Jarzzz it was not picking up on the selector even though it can identify and highlight it…was able to adjust the element and use a wildcard in place of the file name, seems like it did the trick.

1 Like

Jarzzz sequence, though clear, did not work smoothly in my case. I realized when sending hotkey ‘i’, i should indicate the selector for the activity as the Print area, otherwise, the key input fails to register in excel. This resulted in the dropdown being visible. Then comes the challenging part on how to record the selector for the dropdown because as soon as you click outside the dropdown, it collapses!

To navigate this tricky part follow the following steps below:

  1. Click on ‘indicate on screen’ in your activity
  2. While the cursor highlights the different selectors on your screen use the shortcut key Alt+i to make the dropdown visible
  3. Now click the item you want to select off the dropdown list

UIPath should now have recorded the selector correctly.

Hi @cdoughty,

Take a look …

Regards
Balamurugan.S

Hello,

Did you try to run a VBA code on the worksheet?
By doing this, you can also define more parameters and the file path can be passed as an argument:

My below function prints a range in PDF:

Function SaveRangeAsPDF(rng As Range, filePath As String)
        rng.ExportAsFixedFormat Type:=xlTypePDF, filename:=filePath, Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End Function