How to syncronize a working queue with a file directory - blueprism

In Blue Prism, I want my work queue to consist of alle files added to a file directory. The item key is the filename. I solve this by reading all the filenames, and then loop through each one, check if it is in the queue, and if not, add it.
There will be thousands of files in the directory, so I don't want to loop through all files every time the process starts.
Alternatively, using "get all completed items", I can get the itemID of the completed items, but then I have to use "get item data" on each one to get the filename to check if the file needs to be added to the queue. Any better ideas ?

That's a interesting problem.
It must be possible to achieve that by doing SQL query on BP database. If you have an access to it, then this might be the simplest and best solution. I can't help you with that though, as I've never done that.
A simpler solution would be to make a snapshot of the input folder whenever the queue in populated and store it. I've did similar thing in my recent project :)
Example flow that would involve a snapshot:
First, I create an Excel workbook with data from current run (in a sheet "New") and a previous run (in sheet "Old"). I'd save it in some kind of internal location.
Get a list of all input files
Open a previous excel workbook
Remove data from "Old" worksheet
Move data from worksheet "New" to "Old"
Paste a list of all input files to "New" worksheet
Save and close Workbook
Run OleDB query to retrieve a list of files that are in "New" sheet, but are not in "Old" sheet.

Related

Is there a way to make a logbook in excel of files being created?

I want to make a dynamic excel sheet that updates whenever a file is being created into a folder, think of letters. So the sheet needs to extract the name of the letter, the date&time when it is made, the author and so on, into a table in excel. Does anyone knows how to get that filedata?
I already know how to put data in a certain cell using VBA but the thing i get stuck in is how to get that data from a certain folder.
As Ron said, there is no event in VBA to handle that. However, if you want to stick to VBA only, you have basically two options:
You can update your cell whenever the workbook is opened using the Workbook.Open event (https://learn.microsoft.com/en-us/office/vba/api/excel.workbook.open). This is not really dynamic but might be sufficient (depending on your needs).
Other option would be to call a function periodically to check if the folder content has changed (https://learn.microsoft.com/en-us/office/vba/api/excel.application.ontime)... Not very performant, but would work for sure.
For the file data just follow Ron's suggestion.
Hope that helps, MJ.

Update "overdue" formulas in Power Query

I have several files where I have several tasks. Each task has a "to be completed" date attached to it and a formula that calculates whether the task is "overdue" or "not yet due".
To generate a complete overview, I've created one Masterfile and used Power Query to link all these individual files. This works properly, however one issue I can't resolve which is the following:
The Power Query does not refresh the "overdue/not due" formula, when I am refreshing the Query. As such the Masterfile states that tasks that were "not due" at the time I saved the original file, are still not due, although they are in fact "overdue".. I think the Power Query read the original files without updating the formula's.. Is there anyway to resolve this?
There is no easy way to resolve this. Three possible options :
If you want to accomplish this just from within your Masterfile, you can create a VBA script in your Masterfile that opens and closes all linked workbooks (see more info here). Please note that you must have access to these files (can be tricky if these are on a network drive or in the cloud);
You also can just manually open and close the individual files before you open the Masterfile (or before you refresh the data);
Change your approach/formulas, and use the individual files as pure data files, without any formula's that need refreshing, and do all calculations in the Masterfile.
My personal preference/recommendation would be 3), as I have some bad experiences from working with linked workbooks. My own approach if it is really necessary to exchange data between Excel files, is to create a Transfer tab/worksheet in the source workbook where you put all data that the other workbook needs, and create a Source tab/worksheet in the other workbook, and I copy/paste-as-values from one to the other, in particular when both workbooks are "in development". Once workbooks are stable (but does that ever happens?), you still can link the Target>Source worksheets (but auditing errors is just easier instead of having links all over your workbooks).

Exporting data to Excel sheet without writing column names in SSIS

I have this problem. I have to create an Excel 2007 file dynamically. To do so, I have an Excel connection with the "First Row Are Column Names" check uncheked. Then I created a SQL Task with that Excel connection and the following SQL Statement:
CREATE TABLE `MySheet` (`MyColumn` LongText)
And then I have a Data Flow Task that fills the sheet with a single-column stream of data.
The problem is that even though I unchecked the "First Row Are Column Names" check, the exporting still writes "MyColumn" in the first row. I need to be able to export the data from the first row onward, without any other thing being written on it.
This is a problem because there's the possibility that the Excel file must be overwritten by the SSIS package on a different run. Since we don't have deletion permits in the folder where the file is created, I need to delete the contents of the sheet from the previous run. I manage to do this using a SQL Task and the Excel connection with the statement:
DROP TABLE [MySheet]
This manages to erase every row without deleting the sheet. But, since this task is followed by the Data Flow Task instead of the sheet creation task (because the sheet is still there), when the Data Flow Task fills the rows again, it leaves the first row empty. It doesn't re-write the column name.
This difference is what I'm trying to avoid.
Is there any way to avoid this?
Thanks
Short and sweet answer is no. Not possible. It will always have to use something to make it distinct. What you can do is, use a small poweshell script to open the excel file, run a small macro to delete that first row and then save it and close it. There are a lot of powershell scripts that can help you with this.

Batch save pictures from multiple excel files in a folder

I have about 10000 excel files, that in a specific cell of all of them there is a picture. I need a script to read all files and save the picture with the same name of the excel files in a folder.
Could you please help with that?
Thanks.
This method is based on a number of assumptions:
All the files (10000) are located in a know folder,
All files are named according to a paradigm that can be reproduced programmatically (if not, you can get the list of files within the folder, store the list within an array, and loop through the array),
Pictures are always within the same worksheet or, if in more than one, the names of the worksheets can be reproduced programmatically,
The filenames to be used to save the pictures can match (at least as a seed) the one of the Excel the pictures are extracted,
You will manage to write some basic VBA.
Note that for the VBA you have at least two options:
Write it within an EXCEL that will only serve as the extraction engine, or
Write it as a stand-alone file and run it via DOS commands.
The VBA logic:
Create the outer loop that processes a single file,
Within the outer loop, generate the name of a file to be open,
Open the file using Workbooks.Open VBA function,
Select the worksheet and the cell containing the picture,
Use the Workbook.SaveAs to save the picture (you will need to specify the type of file to be used, e.g. .bmp).
As a simple and very efficient tool to get the code (at least) partially generated by Excel, you can RECORD a MACRO for each action and then stop recording. You will see the code generated (you will need to access the VBA mode). You can copy-paste the generated code into your development (you might need to do some simple adaptations though).
That's it.
Hope you manage. Good luck!!

How to pull data from multiple workbooks in Excel?

I am working on designing a PARETO, and I need to pull data from multiple sheets via a single workbook.
So when someone opens this pareto, and push a button, a pareto will be created via the information on another workbook.
Is it possible to get that information without copying it all over?
In English, I have a workbook called Open Order, and another called PARETO. If I push a button in PARETO I want to have it pull data from Open Order, and say ok, 20% of all jobs in Open Order Archive sheet are late... is it possible to do this without having both books open or no?
Yes. As long as one is open it can extract data from the other even when that is closed. BUt I would recommend opening both because extracting a lot of data this way can be (or at least used to be) VERY slow. Apparently each 'Lookup' opens a new instance and does not close it immediatley afterwards.

Resources