I'm trying to automate the addition of a link to a report in OneNote. Basically, I have a already running macro producing a daily report in VBA Excel and saving a values only copy in a given folder. I would now like to add to the code so that an hyperlink is created in OneNote so the end-user may access the values-only file by cliking on that hyperlink.
I've found a piece of VBA code that creates a new page in a Notebook on Microsoft webpage: Create New Page
I have modified the code so that it'll go to the Notebook, Section and then Page I tell it to. Then I can have VBA it fetch back the PageContent through XML format.
Now here's the thing: I have a table for the month that starts only with one line two columns ie. the headers (report date and link). Now everyday, I wish to add a line to that table before writing the day's date and the link.
How would I do that in OneNote with VBA Excel ? Is it possible ? Or would I need to change to VB or C# to be able to use Office-InterOp to do so??
If I manage to create an extra line, I think I'd have no problem finding the two empty cells and writing the date and an hyperlink.
Can someone please help?
thanks
Sebastien
After you get the page content in XML format, you just need to modify it to include the Table (or add new rows/cells to it and then call UpdatePageContent. Here is a sample page XML that has a simple Table:
<one:Page xmlns:one="http://schemas.microsoft.com/office/onenote/2010/onenote">
<one:Outline>
<one:OEChildren>
<one:OE>
<one:Table>
<one:Row>
<one:Cell>
<one:OEChildren>
<one:OE><one:T><![CDATA[Cell1]]></one:T></one:OE>
</one:OEChildren>
</one:Cell>
<one:Cell>
<one:OEChildren>
<one:OE><one:T><![CDATA[Cell2]]></one:T></one:OE>
</one:OEChildren>
</one:Cell>
</one:Row>
<one:Row>
<one:Cell>
<one:OEChildren>
<one:OE><one:T><![CDATA[Cell3]]></one:T></one:OE>
</one:OEChildren>
</one:Cell>
<one:Cell>
<one:OEChildren>
<one:OE><one:T><![CDATA[Cell4]]></one:T></one:OE>
</one:OEChildren>
</one:Cell>
</one:Row>
</one:Table>
</one:OE>
</one:OEChildren>
</one:Outline>
</one:Page>
Related
I have an XML file generated by EasyPower (electrical software). If I open the file in Excel it comes up as a series of formatted sheets like the image below. It appears this way without any prompts or dialogs.
I’m creating a Power Query routine that can extract the data from the sheets. Unfortunately when I use the Power Query wizard to select the XML file as a source, it doesn’t see the data as sheets, but rather a table with columns of Tables, seemingly an infinite number of levels deep. Digging through them I’m unable to clearly see the data. This is not a very good approach.
A work-around is for me to manually open the XML file with Excel and save it as XLSX, then it’s easy to work with the data in Power Query. I know a VBA script could be used to this but my question is, is there a way for Power Query to open an XML file and interpret the layout the same way that Excel does? This way would allow my script to also work within Power BI.
Edit: A sample file has been requested. This link will provide a very simple example containing two worksheets when opened in Excel. EasyPower_Test_Schedule.xml
I just got the permission to try out Power Automate.
We have only one thing running in Excel via VBA and should replace it with a new solution:
What does this Excel VBA:
Filtering Column A for each value in Column A
Copying the filtered content and create a new table with only this content
Take this new table and create a mail-draft for a recipient (mail adress is stored in another column)
Close table/Delete table
next record out of filter array based on Column A
I find many tutorials for Power Automate with iteration over arrays but i have no clue how to generate this initial array of possible criterias out of column A - the part with sending mail (and creating HTML tables within this mail) is shown often.
In addition to asking for access to Power Automate, also ask permission for Office Scripts. This allows you to record (and write) Office Script macro's which you can call from your Power Automate Flows.
The Script bit is needed to manipulate the Excel file and update the separate tables.
See this page for a starter on Office Scripts:
https://jkp-ads.com/Articles/Excel-office-script-basics.asp
And this one for some example scripts:
https://jkp-ads.com/Articles/Excel-office-script-examples.asp
It sounds like you should be looking into Office Scripts. You can find Microsoft's examples on Office Scripts under the Samples section here. And you can find the Stackoverflow forum on Office Scripts here if you have any specific questions.
I have no previous experience in Access, VBA coding or in Excel macros prior to teaching myself the past month via these forums. Thank you forums and contributors. I have enjoyed my Access learnings so far, the challenge that it has provided and appreciate any help that I can get. As such, the code and methods that I have used to this point may well be convoluted and confusing. I will do my best to provide relevant details and accurate terminology.
I work in a lab and I am creating an Access Form for semi-automated reporting. Samples are received from clients and are logged into the Excel Table R&D Log. The worksheet is InProcess. Samples are sorted based on the site in which they originate and given a one or two letter site code (G, D, WH, etc.) and an ID "yy-000" in separate Excel columns (i.e. D 18-096). Samples may be submitted for multiple analyses (Metals, Water, Soil, etc.) and may even have multiple rows of reporting if multiple analytes are identified in the sample. There are several other columns, such as receipt date, reporting date, units, etc. Once samples are reported, I manually copy and paste them into the Archived worksheet, and delete the record and blank row from the InProcess worksheet. Since one sample may have multiple analyses and even more potential results, each record would be reported on a new Excel row (with the same D 18-096 ID number). Thus, there is not a single unique identifier or primary key for each sample in the current format. R&D Log is updated manually by lab technicians and the worksheet InProcess is a linked table in an Access Database.
The Access Database is using two combo boxes on a Form frmInProcess to filter a Query qryInProcess of the linked table. The combo boxes are filtering the report destination (one client may receive multiple site codes) and the analysis (reports are separated based on type of analysis). The Query is also filtering out blank results and blank dates, so only completed samples will appear on the filtered Form. I have generated VBA code to this point that will export the Form to a .pdf, save the file with unique filename, and open outlook to mail out the report. I have also managed to export the filtered Form frmInProcess to an Excel file Access Test (not the linked file).
What I would like to do now is to automate the transfer of completed test results from the Excel worksheet R&D Log: InProcess to R&D Log: Archived and delete the record from the InProcess worksheet. I am not sure if I can export the filtered Form into a linked Excel table, or if I must use a separate Excel file (or if it even matters for simplicity of code?). I would now like to read the exported filtered Form in Excel Access Test, lookup matching rows in R&D Log based on several criteria (site, ID, Analysis, Analyte, Report Date) and automate the transfer of records between R&D Log worksheets. End result being that Access generates reports for completed tests, and the records are removed from InProcess testing and transferred to Archived testing in Excel. I am guessing that I may need to close the Access application and perform this in Excel. Hope this is easy enough to follow.
Thank you.
In my experience, importing an Excel document into a temporary NEW (or totally empty) Access table is usually the easiest way to go. Then you do not have to worry about cell references like you do in Excel VBA. Even if the Excel document has old data in it with just a few new changes each time, importing it into a temporary Access table could be the simplest way to go, because then you can compare the data in this table with the data in another, permanent Access table and update the latter based on the former.
As far as the original Excel file, if you need to delete rows there, it might be quicker to export a new Excel file with just the data the old one is supposed to end up with, and then use VBA to delete (or - safer! - rename) the old file.
So the development process goes something like this:
Save import steps by first importing an Excel file via Access' ribbon options "External Data" (tab) ->"Excel" and when you finish, be sure to check the "Save import steps" box and note the name you give the "saved import" because you will need that in your VBA code.
In Access, write a function for deleting the table. The VBA code is:
Const cTable = "MyExcelTempTable"
If TableExists(cTable) Then
DoCmd.DeleteObject acTable, cTable
End If
Now you can test your delete function on the data you imported.
Write VBA code to import the same spreadsheet to create the same table:
Const cSavedImport = "Import-MyExcelTempTable"
' Import the Excel file
DoCmd.RunSavedImportExport cSavedImport
Write more VBA function(s) to check the imported table for bad data and then to copy it into the permanent table. You might be updating existing records or adding new ones. Either way, you could use Access queries or SQL to do this and run them from VBA.
Write a VBA function to rename the old Excel file. (You could use an InputBox if the Excel file name is different each time. I do this for importing Excel files, and I set a default value so I do not have to type as much.)
Write a VBA function to export the new version of the Excel file.
Make yourself a button on a form that, when clicked, runs a VBA function. Inside that function, run Steps 2 through 6, above.
I am not sure my answer exactly matches what you are trying to do, but hopefully you get enough of a picture of the workflow to figure out the details of what you need.
I came across web queries option in excel just an hour ago, so please pardon my naivety.
I am trying to pull a table from this page on BLS, however I am getting only first part of the table whereas I need only the second part of the table (or the full table). I am trying to import the part with historical data just below download xlsx button. It is part of the table which starts from "Series Id: CES2000000001" and ends at "P : preliminary". One thing I noticed that the table does not have any id, and excel reads its name as "3"
The table is not in a good format for excel "from web" in the data tab from my test. However, if you download Microsoft's Excel Power Query Add-in (or use Excel 2016) then I found that it detects the table correctly.
After downloading powery query, simply go to the 'Power Query' tab instead of 'data' and select 'from web' and enter the website. You'll get a screen like below.
Please note however, if this is a one time deal you can simply select the HTML table by dragging over it with your mouse, copy it, and paste it directly into excel.
I have a report that I need to update in Excel many times a day using statistics from JIRA. If I can import these directly with code I would save a lot of time and effort.
Is it possible to use a saved JIRA filter in conjunction with the REST API function to import the results to Excel using a VBA macro?
This is a solution does not use REST API, but it may work for you. This is a workaround I am using so far and it works:
Run the Filter in Jira
Export the result list into an excel file using the Export CSV file with the option current field (to avoid having unnecessary fields) and with the right button of mouse select: Open in a new window
Now you will see the URL associated with your filter in a new window of your browser. Your filter is represented by a Filter ID, therefore the query will be always the same.
Go to excel and use the URL as a hyperlink
Every time you click on the hyperlink it will download the file from Jira. You need to have a Jira open sesion in your browser.
Create a VBA marco that click on the hyperlink for downloading the file.
Use Power Query for example for loading the file from the download folder location into a worksheet. Power Query is a new excel feature. Power Query is an ETL tool integrated into excel for loading files and processing them.
The steps 6-7 automates the process. Run the Marco for downloading the file and refresh the content of your worksheet from Data Connection. You can have an additional macro that refreshes the content of the worksheet. It refreshes all pivot tables and the file connection for reading the file.
Hint: Use excel Table for keeping the information updated automatically when additional information is loaded into the worksheet. If you use pivot tables for presenting the data, use as data source an excel table instead of excel range.
It minimizes a lot the manual effort.
Here you can find a solution that uses REST API, the author provides the source code, but it is more complicated. If you need something simple, my solution may work for you.