Add page break in excel with the module ImportExcel (Powershell) - excel

I'm actually trying to generate a large report with multiple groups in powershell. I want to seperate each groups of data in a single page, but I'm struggling to find the method to add a horizontal page break with the ImportExcel module.
I'm starting to wonder if it is doable. I know that it is possible with the excel interlop com object, but the script with be run with an elevated user right on a server, so we do not want to install excel on to.
So far I've look at the module methods and I did not find anything. It seems like we have access to the document/sheets xml so if someone knows how to do it in xml, it could also do the trick.

I'll post my answer since I found it. The module ImportExcel is based on the EPPLUS library for c#.
I've take a look in the library and there is a way to add a break line fairy easly, but does not show in powershell.
$Sheet.Row($line).PageBreak = $true
It's that simple. There is just not obvious documentation and the intellisense was not finding it too.

Related

Using PowerShell to import PDF to Excel

I am searching for a way, to import a PDF into Excel using PowerShell.
So far I found one link that seems to have a solution:
http://allthesystems.com/2020/10/read-text-from-a-pdf-with-powershell/
Following the instructions, I had an error regarding the DLL, which I did unlock as read in some comments. Trying a second attempt, I get the following error:
Is this in combination with [iTextSharp.text.pdf.pdfreader], that it is not able to run the command and if yes, what would I need to do to get it loaded?
Unfortunately, I do not understand, what I am doing wrong and there are no indications or suggestions on the site, that others had a similar issue.
OR maybe:
Within Excel, there is the possibility under "Data" to use "Get-Data --> from File --> From PDF"
Is there a way to use PowerShell to run this step?
Any suggestions and guides welcome, I just try to find a way to have to have PDF files converted and imported into Excel and to automate the process.
Thank you very much for any help and support,
Mike

Referencing VBA code in .vb files (with UiPath Invoke VBA activity)

So I'm not sure if this question requires knowledge on the UiPath software in order to be answered or not. I have been developing a lot of Excel macros for my company, and as I get more and more macros, it's harder to manage them.
We have been working on some robots as well within the company, and I notice that the robot has an activity where you can invoke VBA code within an Excel application scope. This activity reads a .vb file with code and invokes whatever method you specify within that file as a macro in the activated Excel application.
Ideally I would want to extract all my VBA code into separate files, and have the robots execute the macros through this activity. This would make it a lot easier to manage the code.
My question is then, if it is somehow possible for me to also extract the modules I've created that contain utility methods that I repeat throughout many macros into a .vb file, and reference this in the other macro files?
I don't know exactly how this activity invokes the code and what restrictions are placed on it. Within Excel, I can store re-usable methods in modules and call on them from other modules. This is what I want replicated on a file level. If there was some way of adding import statements to the top of the code to retrieve methods from other modules, so I could call them within the file.
My worries (and assumption) is that the activity simply reads it as a text file, and just imports it as a macro right into Excel. That if I wanted to reference any modules within my method, the modules would have to already exist in the Excel application.
I could always paste the utility methods into every .vb file, but that sort of defeats the purpose of making it easier to manage.
Is there anything I can do here?
Thanks,
TRS
You definitely can reference external assemblies (.dlls) in UiPath. I haven't done it with VB.Net Projects, but I have done it with C# Projects which is in this case, the same thing.
Please, follow this tutorial: https://www.uipath.com/kb-articles/how-to-include-external-dll
To be able to generate the .dll, you will need to download Visual Studio Community Edition and follow a couple of tutorials on how to compile VB code.
All your VB code will exist in this .dll. This would be your general repository or main library that you would access every time that you need it. As I understand, this is your main goal anyway right? "To access utility methods".
I don't know if inside your macros, you use specific Excel references that could lead to compilation issues. So, be ready to reference everything that you need inside the code.
At the end, to access your custom methods, you would need to reference the .dll and use the activity called: Invoke Method.
I hope this helps.

Convert XLS to CSV without login

I have a PowerShell script to convert my XLS files to CSV every week. The script works well, but I have to run it manually as a login user to trigger an Excel instance in the background on my computer (as shown below).
$Excel_app = new-object -ComObject Excel.Application
I was wondering if anyone could give me some advice on how to automate this process, for example, if even my computer is logged out, the converting would still happen etc.
I am also open to rewrite the script in other languages, but I am not sure if others would also require a login user to open Excel etc.
Thanks in advance!
You can use Task Scheduler to run the task without a user logged in, but you may have to configure the DCOM permissions to get it to work non-interactively.
A better solution might be to use the ImportExcel PowerShell module, which is based on EPPlus so it doesn't need Excel at all. That should just work from Task Scheduler since there's no COM Objects at all, but there's a small chance of incompatibility if you're doing something particularly unusual with your Excel documents. It also has the advantage of not requiring Excel to be installed.

How to create excel 2013 timeline from access

It's my first question here so please be easy on me..
I'm trying to create an excel report from a dataset i've created in MS Access as part of a MS-Access based large project.
This project has to run on many machines and to avoid reference errors i use late-binding.
My problem is that when i try to create (from Access) a Timeline using the "Slicercaches.add2" method my code fires error "5". As a test i've created the timeline from Excel-vba and i found that if i use the "XlTimeline" constant it works, but if i use the "2" value not . Is there a way to use the Xltimeline constant inside Access-Vba without reference to excel libraries??
Thanx in advance
MF
First off, welcome to Stack Overflow. Without seeing your VBA code, answering your question would mostly be speculation. As a common practice, it is always beneficial to show the code you're working with (same concept as a picture is worth 1000 words). With that being said, working with Excel objects (or any other office application) requires that you import the necessary libraries. With the Excel library imported, you can essentially do anything to an excel file using the Excel object. Is there a particular reason you would like to refrain from using the Excel library?

Is it possible to store reusable VBA code in a library and call from Outlook?

I have code written in Outlook 2010 VBA that I want to share with co-workers (an Outlook rule runs that calls the code, which saves the current e-mail to a network folder as a text file). What I would like to do is save the VBA code in a library somewhere on the network, and have Outlook call it there. This way, others can call the same code and there is one set of code that all instances of Outlook can point to. If you can point me to info on setting this up I would appreciate it!
I do a similar thing in VBscript programs, using executeglobal to basically run a file containing the functions (acts like an include file) and am looking for how to do it in VBA.
Well it seems its not as easy as I was hoping. After perusing the links supplied by MP24 (Thanks MP24!), I learned the Outlook OTM file is not really intended to be shared. It errored for a colleague when I saved it to a network drive and she tried to use it via tools/references. To share code, one can export it as a .bas file, and another user can import it. This will add it to their own code if some exists already. The proper way seems to be to write an add-in, but that is beyond the scope of what I need for what I am doing. So, if a colleague wants to use my code I'll export and they can import it. The trouble is if I change something they will have to delete it and re-import. Oh well.

Resources