How can I use VBA code to convert a .html file to an existing .xlsm file? - html

I have software that generates a 2x 25,000 table of numbers in an .html format. My current process is opening the .html, saving as Excel workbook, etc.
The goal is to automate the process, import the data to Excel, and generate graphs and box charts. I have used macros to accomplish the latter but I am struggling with getting the .html data into the existing .xlsm.
I have found this code, from a helpful thread on Stack Overflow:
Sub Open_HTML_Save_XLSX()
Workbooks.Open Filename:="C:\Temp\Example.html"
ActiveWorkbook.SaveAs "C:\Temp\Example.xlsx", xlOpenXMLWorkbook
End Sub
However, I'm not sure how to use it. I've been using custom made keyboard shortcuts to access my macros such as Ctrl+Shift+Q. I also don't know how to edit it to suit .xlsm.

Related

R Writing Excel Document

My question is whether or not anybody knows of a better way to do what I'm already doing. I'm creating a report as a list, and trying to render it both in HTML and Excel.
I'm developing a shiny app that generates reports for Qualtrics surveys.
The results table is a list of HTML strings that I paste together and display in a shinydashboard. Here's a dput of the example results tables.
Here's how I'm creating the html results tables list -- the html_tabelize() function in my package. Here's a dput of the example input.
In the shiny server.R file the way I create the Excel file is with the following code:
output$downloadResults <- downloadHandler(
filename = 'tables.xls',
content = function(file) {
write(html_tabelize(main()[['blocks']]), file)
}
)
To summarize: I get the blocks, I run html_tabelize on them, and then I write the HTML output to a file called "tables.xls". When I open that file, because Excel can render HTML, it renders something like this:
My concern and problem with what I'm doing are two-fold:
If I were writing an Excel document instead of simply rendering HTML in Excel, then I could perhaps get a better formatted document. I'd like that.
When you download the results tables xls file and try to open it, you get a warning from Excel. I don't want the users of my app to see this warning, because it's distracting and could worry them about something that isn't really a concern.
I know that options exist for writing Excel files in R, but so far what I've seen indicates that their input must be either a data frame, or a list of data frames. The list I am rendering from has different types of components, like the question text, as well as data frames of results. Originally I was using pandoc, but pandoc, even when run from R, is a system binary, and it's difficult to list as a dependency (and if I can't list it as a dependency, it's tough to make sure it's installed for the users of my app). Additionally, I found out pandoc doesn't even convert to "real" Excel -- it also just saves HTML in a .xls file. Does anybody have any suggestions as to how I can improve this part of my app?

Creating an html formatted file to be opened by Excel

I am trying to export a spreadsheet file from a website. The data is a bit too complex for a simple csv, so I figured the best way to do it was to format it into a file containing nothing but an HTML table. If I give it a .xls extension, it will open, but only after throwing an error and asking for confirmation. Is there a way to set up the file so that Excel knows that it is supposed to have HTML code in it, and so that the OS knows that Excel is supposed to open it?
This is going to be used by people who aren't going think to open Excel and drag the file in or open it from inside Excel. They're going to be double-clicking on the file.

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!

Creating a CSV file with the Report Generation Toolkit in Labview

I want to create .csv files with the Report Generation Toolkit in Labview.
They must actually be .csv files which can be opened with Notepad or something similar.
Creating a .csv is not that hard, it's just a matter of adding the extension to the file name that's going to be created.
If I create a .csv file this way it opens nicely in excel just the way it should, but if I open it in Notepad it shows all kind of characters and it doesn't even come close to the data I wrote to the file.
I create the files with the Labview code below:
Link to image (can't post image yet because I've got to few points)
I know .csv files can be created with the Write to Spreadsheet VI but I would like to use the Report Generation Toolkit because it's pretty easy to add columns and rows to the file and that is something I really need.
you can use the Robust CSV package on the lavag.org forum to read and write 2D arrays to CSV files.
http://lavag.org/files/file/239-robust-csv/
Calling a file "csv" does not make it a CSV file. I never used the toolkit to generate an Excel file, but I'm assuming it creates an XLS or XLSX file, regardless of what extension you give it, which is why you're seeing gibberish (probably XLS, since it's been around for a while and I believe XLSX is XML, not binary).
I'm not sure what your problem is with the write spreadsheet VI. It has an append input, so I assume you can use that to at least add rows directly to a file, although I can't say I ever tried it. I would prefer handling all the data in memory explicitly, where you can easily use the array functions to add rows or columns to the array and then overwrite the entire file.

Code-generation using Excel: Generate HTML from within Excel

Problem:
I have a user who would like to generate an HTML page directly from Excel (without doing file-save as) but instead click a button and have the current worksheet (or a modified variant thereof) contents just 'pop-up' inside a script-generated HTML page. The rationale is that the Excel content could be used to navigate to different web pages automatically, based on the values entered in the cells by the user.
Question:
1) Has anyone done this kind of thing using Excel, and are there any security implications, above and beyond just the ordinary considerations that go with having macros enabled in Excel.
2) Has anyone done this using an alternate methodology?
Why not write a VBA macro that does the "Save As" operation to save the file in HTML format?
You don't even have to record the macro, you could probably record it using the macro recorder.
Start macro recorder
Save As - HTML format
Stop macro recorder
Assign macro to a button