Print MS Access report to .xps file using VBA - ms-access

I am using MS Access 2003 and have seven different reports I have to distribute each morning, and I currently do that manually by printing each to an XPS file. The default printer for each report has been set to XPS file, and I tried this code:
DoCmd.OpenReport ("rptDaily_1of7")
DoCmd.PrintOut acPrintAll,1,,acHigh,1
When I use that, it does open a Save As box, but .tif is the only option in the "Save As type" field. Even if it wasn't though, ideally I'd like to send the file path and name as a parameter and have it handle the entire process (so I can use a loop to generate all seven files with the push of a button). I'm hoping there's another command I can use to do this, or possibly another method. Note that it's not my machine, and I do not have admin rights to install anything else (like a pdf generator, etc.).

You can create your reports as PDF files using ReportToPDF by Stephen Lebans.
This can be easily automated (there is a MDB with example code in the download) and you don't have to install anything.
It comes with two DLLs which you need to put into the same folder as your MDB/MDE, and that's it. No installation / DLL registering, just distribute the two DLLs with your MDB/MDE.
We are using this at work to print thousands of reports per day from Access 2003.

Related

SSIS Error Importing XLS File - External table is not in the expected format

I'm trying to open the following XLS file in SSIS:
https://drive.google.com/file/d/1E_fNSlRTMuoYnH7VERFB8hXbcxssKSGr/view?usp=sharing
I can open it in Excel, without any error or warning from Excel.
But When I try to open it in SSIS or even In PowerBi, I get the following message: "External table is not in the expected format". If I open it in Excel and then Save again in the same XLS format, I can open it in SSIS.
I've installed the following OLE DB Drivers:
AccessDatabaseEngine_X64 (x64)
AccessDatabaseEngine (x86)
And I've tried with the following providers:
Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0;
Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 8.0;
Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;
Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 5.0;
Any idea about why the file is not opening in SSIS?
I don't want to be opening every file, every day, because there are many files every day that I need to load.
I'm using Visual Studio 2019 with projet compatibility for SSIS 2017.
Thanks!
The first issue that the excel reader is going to have is the image sitting there throws the tooling off. As soon as I deleted the image and saved it, the tooling started to work.
The next problem you're going to run into is that you need to skip the first N rows before your data begins. Since there's no functionality in the JET driver to do that, you're going to need to do some magic to work with the data set.
Google the terms Excel, IMEX and registry keys and you'll get into the voodoo of Excel type inference (based on the first 8 rows) and it's ugly.
At this point in my career, I either push back and ask for a cleaner extract of data from the provider. Otherwise, I increase the estimate and write a custom Script Component Source that uses the JET/ACE drivers to extract the data and then shape and type the data into my data flow.

Automatically format .csv file upon download?

I have a form that will open a file based on user's selections. A few files are .csv and those files open up in Excel, as expected. However, everything is placed into one cell... I know that there is a way to manually configure it so that the | or , are delimiters, but is there a way to set it so that Excel will automatically set the | as a delimiter?
Thank you in advance!
Because you use the word "download" and your question is tagged "html", I assume that the user interacts with a web form rather than a desktop form.
In that case, it's the web browser that decides what to do with the file. If the browser recognizes the content-type of the response as something it can handle natively (e.g. "text/plain" or "image/jpeg") then it may open the file and display it directly.
However if the content-type is not something it knows how to deal with (which is likely the case with "application/csv"), then it will download the file and ask the operating system to open it. At that point, the filename assigned to the file (which can be set via the HTTP response) may come into play.
On a Windows machine, the operating system maintains a list of file extensions and actions associated with those extensions. When you install Excel, that will normally make Excel the default "open" action for files with the ".csv" extension. That's why double-clicking on a ".csv" file opens in Excel, and also why it may open in Excel if you download it from a website. (If you didn't have Excel, it may simply ask you what program you want to use).
This is a long-winded way of saying that if you had control over the user's machine you could give the file a different file extension and then associate that extension with an action that did something different. But, I assume that you probably don't have that sort of control unless you're dealing only with in-house users, and anyway it would not be a trivial thing to achieve.
I don't think that there's any way to communicate to Excel via the command line that it should use a particular delimiter when opening a CSV file, and that - unfortunately - is the mechanism by which the operating system will ultimately open the file.
It is possible to control what Excel uses as the default delimiter for all CSV files (see https://superuser.com/a/606274/18472) but again that would require you to change the system-wide settings on your users' machines, which I imagine would not be possible.

SSIS package to upload escel where user will be presented with a file picker window to choose file to be uploaded

I have a requirement wherein I will be executing an SSIS package from a command button on an MS Access front end. The requirement is to present a file picker window which will let user choose file to be uploaded and then once chosen it should be inserted into table in SQL Server.
Kindly let me know if this option can be made available in the package.
No, you cannot make this option available in an SSIS package.
The way I have handled this in the past is to write a .net application that uses the file picker to let the user choose the file, and then stores the user's filename/path in a table, and launches a job that calls the SSIS package, which gets the filename/path from the table, and then uploads that file.
I assume you can do the same with a MS Access front end, but I am not an Access expert.

Merge multiple access reports to one pdf file using vba

I wan't to merge multiple access reports to one pdf file using vba code. This vba code needs to work on the computers at my work. These computers only contain Adobe Reader, and I am not able to install Acrobat because I am not Administrator. So now my code generates for all the reports a seperate pdf. I had some code to merge these pdf files to one pdf file where I use 'Acrobat.CAcroApp'. But i get an error on line:
Set AcroApp = CreateObject("AcroExch.App")
I think I am not able to do this cause the computers only have Adobe Reader installed. Is there a possibility to create one pdf file for multiple reports/pdfs without using Acrobat.
Thx in advance
2 solutions.
Make a master report that has each individual report embedded as a sub report. If it's just a few, it should work fine, but too many may bog down / crash the application.
Here's a VBA way of doing it here.
Without acrobat reader this is indeed not going to work. I, however, am using the following dirty workaround for users without acrobat;
Export all your reports to rich text ("*.RTF" format) in the same folder. Afterwards, you open a word application via access vba, and loop through the RTF files and then copy them into your word file, with a page break after every insert. Then, you save the word document as a .PDF file.
This is a method prone to errors, so if a more experienced user has a better way, please do tell. I'm interested as well!

how to export datagrid to excel(.xlsx format only) without using server side technology and as3xls?

Presently I am using as3xls.swc to export datagrid to excel which is giving me only to save as .xls format which is opening in microsoft excel 2010 which is OK for me, but it is only opening in protected mode where I am unable to do any edits or save it. So, can anybody know any other way to save as .xlsx format in the client side itself?
Protected mode is a feature of Excel within the Microsoft operating system. They're trying to keep you from inadvertently downloading viruses. You can defeat these measures by modifying the Excel trust store. It has nothing to do with your code, and you don't need to use older versions of Excel.
I find it easiest to add a trusted location (like your desktop).
http://office.microsoft.com/en-us/excel-help/what-is-protected-view-HA010355931.aspx
You can export to Excel2007 - its just an xml file format. WE have some details on our blog: http://blog.flexicious.com/post/Flexicious-30-Release-Grid-Edition.aspx. Keep in mind however, it generates an XML file, which when you double click on, will correctly open up excel (Assuming you have excel 2007 or the reader installed).