Excel 2010 late binding on Access 2010 Project - excel

So i have this typical problem of distributing an Access application to a client. The application is written in Access 2010 and recently i addded some code to export Excel sheets. Therefore i added the excel object library version 14.0.
My clients that run Excel 2007 cannot run the application anymore getting the infamous error: "mssing or broken reference to the file excel exe version 1.7". The question is this:
If i use LateBinding, will the added functionality be available to them ?
I wish to apologise if the question sounds naive but i am new to VBA.

Yes, the functionality should be available, UNLESS you use features that were not available in 2007 (Some table theme formatting using patterns for example is 2010plus) then you should have no issues using late binding.
I guess the easiest is to simply try. Ideal would be to have a virtual PC running Office 2007 and develop using that, when you are targeting client using a lower version than yourself.
Hope that helps.

Related

How to create an installation file for a document-level VSTO template?

This is hardly the first time this question has been asked, but there are no completely satisfactory answers that have been presented, and nearly ALL of them rely upon Microsoft's error-laden developer documentation.
After creating a vb.net VSTO Excel Template project using Visual Studio 2019 with Office 2016 and porting exiting VBA code to vb.net, I have run into a brick wall. I was able to convert the code to vb.net without too much trouble, and thanks to the .net libraries, I was able to include additional functionality that before was impossible with VBA (e.g. Action Panel menus, etc.). But now I cannot distribute the solution to my employees because I cannot create a setup file that will allow the template code to run correctly when the resulting document is saved to any location other than where it was first installed.
I have tried using the supposedly simple ClickOnce method. I have tried the Windows Installer method. We don't have a Sharepoint server (we are a small company) and I don't want to learn how to create one. I have followed the examples at
https://learn.microsoft.com/en-us/visualstudio/vsto/deploying-an-office-solution-by-using-windows-installer?view=vs-2019
and
https://learn.microsoft.com/en-us/visualstudio/vsto/deploying-an-office-solution-by-using-clickonce?view=vs-2019
and
https://learn.microsoft.com/en-us/visualstudio/vsto/deploying-a-vsto-solution-by-using-windows-installer?view=vs-2019#to-build-the-setup-project
and several other Microsoft Visual Studio VSTO instructional articles to no avail. I still cannot get the resulting template file to reference the necessary libraries when the template is moved or saved to any location on a user's computer other than its original install folder. This pretty much makes the solution useless to me. You would think something this important to so many VBA users would be a priority to Microsoft, but it clearly is not. Microsoft refuses to fix/update its documentation, and it ignores vb.net like Microsoft's own policies had nothing to do with why so many of us use it.
I would post my code, but I have no idea what code, in what has now become a rather complicated solution, is causing the problem. My only clue is the error message, which appears whenever the Excel workbook is saved somewhere else and states that "my solution".vsto could not be downloaded because Office is looking under where the template is now stored rather than the original installation directory.

How to port OneNote 2010 vba scripts (hosted in a XLSM file) to work in Onenote 2016

I would need help to get unstuck in porting from Onenote 2010 to OneNote 2016 an Excel VBA host toolkit I made
TLDR:
a) what object libraries should I actually see/reference if I want to use Excel 2016 VBA host to automate OneNote 2016 (desktop app)? I seem to be able to link only to Onenote 12 object library, there is a V15 libray but yields "name conflict" error when I try to reference even if I unclick the rest. Is my installation wrong? (Win10+Excel/ON 2016 32 Bits)
b) how the vba call to getpagecontent() should be in OneNote 2016, in particular what is the schema parameter, a string constant?, should I care?
Longer version
In https://github.com/jceresearch/onenote_vba_host (public) , I maintain an Excel spreadsheet with a few scripts to do things like exporting in bulk pages as an individual doc/pdf, including its embedded files alongside. Also does auto numbering of pages, and auto adding things in pages. It adds a menu in the ribbon you can see there the options.
The code is messy but works with Onenote 2010 fine. I will need soon to work in 2016.
The key part of the 2016 code is in the class code, to call the OneNote up:
Set app = New OneNote12.Application
In my 2010 code/installation it is already OneNote14.Application, but the version of office 365 I have allows me to refer to the Onenote12 object library only.
There is also a "Microsoft OneNote 15.0 types" library but when I click it it yields error of name conflict, even if I remove the old library. There is also an extended type library that again Excel doesn't let me refer to.
So current referenced libraries are:
Microsoft Office 16.0 object library (needed for the extra ribbon element added)
Microsoft OneNote 12.0 object library
Microsoft XML, V3.0 (I had to downgrade from the V6 that Excel suggests by default)
Microsoft Forms 2.0 Object library
Microsoft VBScript Regular Expressions 5.5
With these, I can run the macros and call the OneNote app, even get the list of notebooks and sections.
However, OneNote crashes miserably when the host tries to run:
app.getPageContent sNodeID, sXML, piAll
I tried a few things like bringing just the basic data but same results, also tried various other notebooks, pages, sections.
I assume the issue may have to do with the old version of the object library and/or that in the documentation of getpagecontent there is a mention to using the xsSchema parameter (xs2013 etc). See https://learn.microsoft.com/en-us/office/client-developer/onenote/application-interface-onenote
Any ideas welcomed, and btw, if someone wants to help improve the toolkit, more than welcomed, get in touch.
Thanks!
Here is the solution I found by trial and error:
a. I made a silly mistake I didn't realise till I tested things in isolation. My class name I believe clashed with one of the newer libraries (clsOneNoteHandler possibly). Changing to a unique name seemed to solve most of the problems, notably preventing the load of the latest object library and ultimately making OneNote crash.
b. I managed to link to the Onenote 15.0 object library (not the extended one), and that seems to be compatible with my 2010 code. I noticed it runs noticeably slower (same machine after re imaging to windows 10 with office 2016 32 bits).
c. I Still kept the Microsoft XML, V3.0 library referenced and syntax to parse the onenote XML content, and works fine as far as I can see.
I need to keep regression testing it, but to me the most important feature was to to export pages as docs and its embedded files, and that still works in Onenote 2016.
Hope this will help someone somewhere there.
Regards and thanks for the comments!

How to write to an excel document without having microsoft excel not installed on the server?

I was wondering, if I don't have excel office product not installed on my server, how can I write to an excel document using .net code? I know there's a Microsoft.Inerop.Excel assembly that will assits in this, but it doesn't work for me. I get a CLSID id error where is looking for this particualr guid, but its not installed on my machine. I have the Interop assemblies installed on my server, but I can't use the Excell.Application object. Is there another object that i can use instaed of Excel.Application() to create an excel document on a server where the offce excel product is not installed on? Also my box is 64 bit running SharePoint, if you have any alteratives using SharePoint 2010 I would like to hear about them as well.
Thank You,
There are several Third Party tools, commercial ones like Spire.xls (which we have used, and it works quite well) and freeware, like excellibrary (http://code.google.com/p/excellibrary/).
This has been asked before, see Create Excel (.XLS and .XLSX) file from C# (guess someone may close that question).

Access to excel file in the server without installing excel

I've created a library to pass/get data to/from excel.
To execute in my machine i modified the access permisions in COM+ console.
The thing is that im interested in upload this component to my online server, but there i havent installed excel.
Are there any way to register excel in COM+ without install excel?
Thanks in advance.
Best Regards.
Jose
If your library uses Office Interops to manipulate Excel, then no you can't register Excel in COM+ without installing Excel, since there would be nothing to register against, or interop for that matter.
Even if you use late binding in your code, so that it compiles, you will experience runtime errors if the Excel components are not installed.
"All current versions of Microsoft Office were designed, tested, and configured to run as end-user products on a client workstation. They assume an interactive desktop and user profile. They do not provide the level of reentrancy or security that is necessary to meet the needs of server-side components that are designed to run unattended." - http://support.microsoft.com/kb/257757

Excel & Microsoft.Office.Interop

I want to use the Microsoft.Office.Interop to read an Excel file from a web page.
Do I need to have Office installed on my web server?
I am not doing any manipulation to the excel file, just reading it in and storing the values to another page. I have no issues when I run on my local machine but I have Excel installed on my local machine. Anyone that knows this answer I would greatly appreciate your input.
Thanks
JD
Using Interop requires that you have Office installed on the server. For websites, I would generally recommend using something like the open-source NPOI project. However, if all you ever want to do is read, consider using ADO.NET (see this question for more info).
I would add that if your using Excel as a datasource the ADO approach is much faster and requires less overhead. It restricts you to excel sheets that are pretty much structured as flat tables. But if I can use that method (all restrictions considered) I prefer it.
Ernie

Resources