question

MicheleHobson-8997 avatar image
0 Votes"
MicheleHobson-8997 asked emilyhua-msft commented

Once I determine that Excel is installed on Windows, how can I programmatically tell if it is a licensed/registered copy using vb.net or C#

While I was working on my application, my Office 365 subscription expired. The application has an export feature that will export the data into Excel if installed or open it as a formatted text document if not.

Although the subscription is expired, it still opens Excel.

Is there any way to check whether Excel is licensed/registered?

Code used to check for Excel installation:

Dim regKey As Object = My.Computer.Registry.ClassesRoot.OpenSubKey("Excel.Application", False).OpenSubKey("CurVer", False)
If regKey.GetValue("").ToString() Is Nothing Then
Return False
Else
Return True
End If

office-excel-itprooffice-vsto-com-dev
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.

1 Answer

emilyhua-msft avatar image
0 Votes"
emilyhua-msft answered emilyhua-msft commented

@MicheleHobson-8997

As tag "office-excel-itpro" focuses on general issue of Excel client. If you need the code of C#, I would like to suggest you post a new thread on Q&A forum with tag "dotnet-csharp", and confirm whether this team could help you. Thanks for your understanding.

From the perspective of Office, you could use command below to check license status, such as Licensed, Notification or others.
Search CMD, right-click the Command Prompt and run as administrator. Then copy and paste the command below in it, click Enter at last:
cscript.exe "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" /dstatus
(If you are running 32-bit Office on a 64-bit operating system)
cscript.exe "%ProgramFiles(x86)%\Microsoft Office\Office16\ospp.vbs" /dstatus


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



· 4
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.

Thank you for your help.

I am unfamiliar with the syntax of this site's tags. I tried to use tags that applied to my question, but none of them were found, they were all removed, and it didn't offer any suggestions.

Using your supplied command I was able to get the information shown below.

I never used a trial version of Office on this laptop, so in any situation would everyone have the ERROR DESCRIPTION listed below?

LICENSE NAME: Office 16, Office16O365ProPlusR_Grace edition
LICENSE DESCRIPTION: Office 16, RETAIL(Grace) channel
LICENSE STATUS: ---NOTIFICATIONS--- Is this the status for everyone who has an inactive copy of Office installed
ERROR CODE: 0xC004F009 Is this the error code for everyone who has an inactive copy of Office installed
ERROR DESCRIPTION: The Software Licensing Service reported that the grace period expired.


0 Votes 0 ·

Hi @MicheleHobson-8997
According to your shareing, your Microsoft 365 apps are not activated.

LICENSE STATUS: ---NOTIFICATIONS--- Is this the status for everyone who has an inactive copy of Office installed

As Microsoft 365 Apps is licensed on a “per user” basis, if you are an administrator and assign some license accounts to others, under the case that the subscriptions has been expired, everyone will be prompted to activate Microsoft 365 Apps.

ERROR CODE: 0xC004F009 Is this the error code for everyone who has an inactive copy of Office installed

If other people run this command to check the activation information of Office, they may encounter the same error message, but it may also be different when Office needs to be activated.

0 Votes 0 ·

Thank you for all your help, but there are too many possible outcomes with the solution you provided. As the final step in my testing I decided to install Microsoft 365 on my development computer and run your supplied command. It returned the following message. <No installed product keys detected>

Installing Microsoft 365 had no impact on the messages I received before its installation. The license status and error code messages remained the same. I then decided to delete Office to create a clean slate and reinstall it again. That is when I received the message <No installed product keys detected>.

It may be best for the continuity of my application and my sanity if I just eliminate the need for office products and go with a solution like SpreadSheetLight on NuGet

Also, is there anything I should do to mark this conversation as closed?

Again, thank you for your help

0 Votes 0 ·
Show more comments