Creating MS Word Doc ... Works Fine w/Windows 7 ... Crashes w/Windows 10

I’ve been creating an application that among other things creates a MS Word doc as an output. Everything works fine when I run the program on my Dell Laptop with Windows 7 Ultimate. But when I run the program on my customer’s computer, a new Microsoft Surface Pro using Windows 10, the app crashes giving the following error:

ole exception invalid class string error number -2147221005

In googling that error, the only thing I can find is that some folks felt it had to do with an incorrect (corrupted?) installation of MS Office that left incorrect registry key values. My customer is a large company ($2B annual revenue) whose IT folks assure me that they have checked the Surface and there is nothing wrong with the installation.

The following few lines of code will precipitate the error with the crash occurring on the line containing Word.Visible = true … where the program attempts to open MS Word.

[code] // Add a new Word Document
Dim Word as new WordApplication


Word.Visible = True // show the result of the created doc

Anyone have any ideas what is really causing this? What can I try to circumvent the error and subsequent crash?

Thanks in advance for your time and consideration.

Do you have the same error if you change the code to:

// Add a new Word Document Dim Word as new WordApplication Word.Visible = True Word.Documents.Add

This error happen when Word is not running or also when Word is already running?

Thanks for your response, Alberto. It will be tomorrow before I get my hands on my customer’s computer again and can try your suggested reordering of the code. I’m beginning to think that I’m going to have to bite the bullet and purchase a MS Surface Pro to use as a test platform … I was trying to avoid this since this is the only job I’ve had (so far, at least) that requires that deployment.

… Both

Do you have the same Word version than your client’s Surface Pro?
Can you test a VM with Windows 10 and office to see if there is any difference than Windows 7?

I’m interested in your findings, I’m creating Excel worksheets and plan to output some things to Word too. Is a personal project right now but you never know when you may need it to work for others.

Sorry, my main PC is in for warranty repairs or I’d spin up some VMs and test Word installed via Click-to-Run and see if that causes the issue, might be worth a test if you can.

[quote=433925:@Alberto De Poo]Do you have the same error if you change the code to:

// Add a new Word Document Dim Word as new WordApplication Word.Visible = True Word.Documents.Add[/quote]

I am interested to know if Alberto’s suggestion of adding the “word.documents.add” line will solve the problems on the computer. I have run into this before as some VBA commands don’t seem to work unless a blank document has been added. This issue was seen on my surface pro I and on my Surface Book I computers.

Julian … Wow! The exact same thing … rather than googling the error like I did, I should’ve looked on our forum here first (I made the erroneous assumption that the problem was one of those “far out” things that nobody here probably ever encountered … WRONG!)

… just got the OK from the customer to go out and buy a Surface Pro to use as a test platform (I like this kind of customer!). I’m headed down to Best Buy this afternoon to purchase it. I’ll try the various suggestions y’all have given me and report back on what I find. One way or the other, I need to resolve the issue since this project has a HUGE impact on the customer and their brand identity with one of their largest customers.

… Yep … we’re both using MS Office 365

It’s just fortunate that my memory isn’t failing that quickly :wink:

It might be tricky to replicate if they perform some kind of corporate schmoo on the device in terms of pushing apps to it after registering the account to the company/domain etc.

It might also be worth PM’ing Jay to see if he ever resolved it and if so, how.

Ahh, this is a temporary PC without office installed, I’m bored, I’ll have a tinker :wink:

OK … Unfortunately, our local Best Buy does not have the exact model I need to mirror the customer’s tablet, which BTW is “Microsoft Surface Pro 6 Model 1796 (FKG-00001)”. I’ve just ordered it from Amazon and it will be here somewhere between Wednesday and Friday of next week. I’ll load Office 365 on it and give it a whirl with the things y’all have given me to try. I should be posting an update to this thread with the results by the end of next week.

Thanks again for the helpful ideas … I’ll be back with the results.

See if you can find out if they deploy their office edition using App-V ?

I’ll make an inquiry of their IT folks and see what I can find out, Julian.

[quote=433925:@Alberto De Poo]Do you have the same error if you change the code to:

// Add a new Word Document
Dim Word as new WordApplication
Word.Visible = True

BINGO!!! Alberto’s suggestion fixed the crash. Got my new Surface PRO 6 and tried Alberto’s suggestion first. So, juxtaposing the calls by opening Word first (Word.Visible = true) then adding the document (Word.Documents.Add) is necessary to avoid crashing the app.

The answer I got was just “No” (no further explanation given)

BTW … REALLY loving this new Surface PRO 6 … very slick in many ways and lightning fast operation.