question

ErikProtzman-9516 avatar image
0 Votes"
ErikProtzman-9516 asked Viorel-1 edited

VSTO Globals Returns Null When Called Across Projects

I have a VSTO workbook which has been developed over the last few years, there is a lot of code in it.
We are migrating this to a cloud based solution.
I want to develop some automated testing to ensure the results from the cloud solution match the existing VSTO workbook.

My approach was to do this.
1. Add a new VSTO workbook to the same solution in a 2nd project
2. Have this 2nd excel file open the main project, change some variables, call a number of modules in that file and then compare against the cloud results.
3. Store the results in the 2nd project of each test, and then close main file.
4. Repeat hundreds of times.

The issue I have is that when I execute a Function like this from within the Main project I get no issues:

 Public Shared Function MyWorkbookName() As String
     Dim s_Result As String
     s_Result = Globals.ThisWorkbook.FullName
     Return s_Result
 End Function

When I call a function like this from the 2nd project though (the function sits in the Main project, but the 2nd file tries to access its result)
I get this error:
System.NullReferenceException: 'Object reference not set to an instance of an object'

156834-image.png



I would appreciate any guidance or alternative approaches to what i'm trying to do.

office-vba-devoffice-excel-itprooffice-vsto-com-devvs-testing
image.png (36.5 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


How does the second workbook manipulate the first workbook?

Instead of two workbooks, maybe it is possible to create an extended variant of the first one to include some special automatic testing features.


0 Votes 0 ·

0 Answers