Help with For Each activity and save as PDF

Hello and thank you in advance for any help.

I have a couple of issues with what I’ve attached. I’ve attached the UI Path project I am working on and I’ve also attached the data table and the Excel template.

The first three pieces of this project work fine

1.Open DS LOA Ishare
2.Data scraping
3. Excel - save the table

Once I’ve saved the data table I’m using a for each loop to iterate through it and pull out each waybill number (the variable is “awb” without quotes).

The problem I’m having is that I can’t get the For Each loop to work correctly. The For Each loop is supposed to pull each awb and paste it into cell F8 of the attached Excel template (called DS LOA template) and then save it as a PDF with the awb variable as the PDF name. For example, if the first awb is 123456789, the first saved template would similarly be named 1234567899.pdf. Right now it saves the first only but the file name is awb.pdf. The other issue is that the for each is pulling the wrong column of data. Instead of pasting the awb variable it is pasting the column with the employee names.

Can someone take a look and help me? I feel like I’m close but not close enough

Main.xaml (28.1 KB)
DSLOA - datatable.xlsx (9.4 KB) DS LOA Template.xlsx (32.6 KB)

Main (1).xaml (11.9 KB)

I have just kept the code which you had issue with. Please check and let me know if you have any questions.

Also saving an excel file as pdf will only corrupt it.

Thanks,
KJ

Thank you very much! This is a big step forward. It appears to be opening the template and I can see it pasting in the waybill numbers but it is then saving the template with the same name instead of saving as the name awb + “pdf” or awb + “xlsx”. How do I correct this? If PDF isn’t an option then I can save as Excel but how do I do that? And how does saving as a PDF corrupt the file?
Thanks again for your help.

Hello again,
I did some digging and it is saving the files with the correct file names but it is saving them in the UI Path directory where the project resides. The problem is that the files are all corrupted. Is there a fix?

I’ve corrected the directory issue but is there a fix for the corrupted PDFs?

Would adding a delay resolve the corruption?

Hi @mworth123

The files are corrupted because you can’t directly convert .xlsx to .pdf files.
You will have to do that manually or use screen recording to save as each file.
Also tag me with @ so I get notification else its tough to track.

Cheers,
KJ

@kunalj - Thank you KJ,

Is it possible to use screen recording to save as PDF with a variable? I need the file name to be the variable strAWB and that changes each time. Also, an analyst friend of mine suggested using Key Down but I can’t find it in UIPath. Is that an option?

Thank you again for the help

@mworth123
Yes its possible to save pdf using a variable.
In the “typeinto” activity you can use strAWB+“.pdf” and that should do the trick.

Regarding Key Down, I am not aware of what it means or how it can be used.

Thanks,
KJ

@kunalj - Thank you, my error - Key Down is actually a Click Text activity with a Click Type of Click_Down and I’ve set the occurrence field to 24 to go down 24 times to where the PDF resides. Your way seems easier so I’ll try that. Thank you again

@mworth123 Yeah type into activity is much easier and faster. And if this works out for you, mark any of the replies as your solution so if someone refers to it, knows that this thread is resolved.

Cheers,
KJ