-
Oct 12th, 2018, 01:34 PM
#1
CreateObject("Word.Application") very slow with Word version 16
It takes exactly 3 seconds at that line in a computer with an I5 processor at 3.89 GHz.
Could be that considered normal?
That line used to take negligible time with older Office versions and in much slower computers.
That causes a problem in the usability of some screens where I offer to edit Word files, because the user clicks to edit a document and nothing happens for several seconds.
Then, if the user closes that document and opens a new one, again she/he needs to wait several seconds while nothing happens.
I'm thinking to keep the Word object instantiation opened (to speed up at least the second and further editions), but before I go that route I wanted to consult with you, if you know something about this issue.
Thanks.
-
Oct 13th, 2018, 04:27 PM
#2
Re: CreateObject("Word.Application") very slow with Word version 16
Do you absolutely have to use late binding? Switching to early binding should speed it up considerably.
-
Oct 13th, 2018, 04:42 PM
#3
Re: CreateObject("Word.Application") very slow with Word version 16
Originally Posted by fafalone
Do you absolutely have to use late binding? Switching to early binding should speed it up considerably.
I suppose that yes... I target any version of Word that could be installed from 2003 to 16.
I never worked with early binding for Office.
What would happen if I reference Word 2003?
And what happens if there is no Word installed on the machine.
I think the program can't even enter to that form. (I'm asking because I don't remember)
Last edited by Eduardo-; Oct 13th, 2018 at 05:08 PM.
-
Oct 13th, 2018, 05:14 PM
#4
Re: CreateObject("Word.Application") very slow with Word version 16
What would happen if I reference Word 2003?
any reference to an uninstalled version of word will result in missing reference, even if the reference is not used, this will cause problems throughout the code
i would have to give consideration to creating the word application object in background, just in case the user wanted it at some point, just make sure to close with program
if the user could already have word open, you could use the existing instance of word, rather than creating an additional instance, but you would need to make sure to leave in the same state on closing
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 13th, 2018, 05:31 PM
#5
Re: CreateObject("Word.Application") very slow with Word version 16
Originally Posted by westconn1
any reference to an uninstalled version of word will result in missing reference, even if the reference is not used, this will cause problems throughout the code
i would have to give consideration to creating the word application object in background, just in case the user wanted it at some point, just make sure to close with program
if the user could already have word open, you could use the existing instance of word, rather than creating an additional instance, but you would need to make sure to leave in the same state on closing
Thank you.
I have some utilities in the program that use Word but are not always used, only sometimes.
My idea now is to start the instance of Word the first time it is needed and leave it open until the user closes that screen.
I can't believe that it was something that used to take just milliseconds in Office versions 15 years old and machines also 15 years old and now with a machine that is 100 timer faster it takes three seconds.
These people must hate that their products are used.
-
Oct 13th, 2018, 06:06 PM
#6
Re: CreateObject("Word.Application") very slow with Word version 16
Originally Posted by Eduardo-
I suppose that yes... I target any version of Word that could be installed from 2003 to 16.
I never worked with early binding for Office.
What would happen if I reference Word 2003?
And what happens if there is no Word installed on the machine.
I think the program can't even enter to that form. (I'm asking because I don't remember)
When you use early binding, the newer version will be automatically loaded. You'd reference the earliest version you support; if you add a reference to e.g. Word 8.0 Object Library, then run on a machine with 9.0, the Word 9.0 Object Library would be loaded.
If Word wasn't installed at all you'd get a local error, probably 'can't create object' on Set = New; you'd trap it like any other and handle the same way as when CreateObject fails.
-
Oct 13th, 2018, 06:21 PM
#7
Re: CreateObject("Word.Application") very slow with Word version 16
Originally Posted by fafalone
If Word wasn't installed at all you'd get a local error, probably 'can't create object' on Set = New; you'd trap it like any other and handle the same way as when CreateObject fails.
Humm, but that's not what happens with other missing references.
I think you get the error as soon as you enter the procedure, or the form (or the module), depending on the scope of the variable that is referencing it.
-
Oct 13th, 2018, 06:26 PM
#8
Re: CreateObject("Word.Application") very slow with Word version 16
Other problem of switching to early binding is that I'll need Word 2003 installed in any machine where I'll work in development of this program.
Currently I can work on any machine as soon as I install VB6.
-
Oct 13th, 2018, 06:54 PM
#9
Fanatic Member
Re: CreateObject("Word.Application") very slow with Word version 16
I don't think the problem is early/late binding. Some other possibilities could be slow addins, a problem with the normal template, hardware, or just a faulty office install. I never thought the last was an issue, but after working in a large company for a while I can say that it does happen.
Since one of your concerns is the user experience, you could open something that indicates that word is starting up in the background. When it gets hung there, the user will know what's going on and put the blame where it's due.
-
Oct 13th, 2018, 07:16 PM
#10
Re: CreateObject("Word.Application") very slow with Word version 16
err yeah nevermind I was thinking of something else with the errors; you'd get user-defined type not defined and not be able to compile.
I don't think you'd need a full blown install of 2003 though just the referenced file.
It's do-able, just a question of how much effort those seconds are worth. Maybe someone smarter than me will pop in with another way to speed it up.
-
Oct 13th, 2018, 07:28 PM
#11
Re: CreateObject("Word.Application") very slow with Word version 16
one possible delay is that so many of these programs now connect to the internet (if possible) to validate when opening
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 14th, 2018, 05:58 AM
#12
Re: CreateObject("Word.Application") very slow with Word version 16
Originally Posted by dmaruca
I don't think the problem is early/late binding. Some other possibilities could be slow addins, a problem with the normal template, hardware, or just a faulty office install. I never thought the last was an issue, but after working in a large company for a while I can say that it does happen.
If anyone else has Word 16 and could test:
Code:
Private Sub Form_Load()
Dim t
Dim w As Object
t = Timer
Set w = CreateObject("Word.Application")
MsgBox Int((Timer - t) * 1000) / 1000
End Sub
Originally Posted by dmaruca
Since one of your concerns is the user experience, you could open something that indicates that word is starting up in the background. When it gets hung there, the user will know what's going on and put the blame where it's due.
Or I could put a message "next version will work with Open Office".
Originally Posted by westconn1
one possible delay is that so many of these programs now connect to the internet (if possible) to validate when opening
But every time? Still, I think it would be usually faster than three seconds.
I have installed a program (Glasswire) that notifies when programs connect to intenet, but it doesn't tell anything when the Word instance is created.
-
Oct 15th, 2018, 01:52 AM
#13
Re: CreateObject("Word.Application") very slow with Word version 16
Code:
Private Sub Form_Load()
Dim t
Dim w As Object
t = Timer
Set w = CreateObject("Word.Application")
MsgBox Int((Timer - t) * 1000) / 1000
End Sub
Took 1.7 seconds on my machine (running from an SSD)
-
Oct 15th, 2018, 05:25 AM
#14
Re: CreateObject("Word.Application") very slow with Word version 16
Originally Posted by Arnoutdv
Code:
Private Sub Form_Load()
Dim t
Dim w As Object
t = Timer
Set w = CreateObject("Word.Application")
MsgBox Int((Timer - t) * 1000) / 1000
End Sub
Took 1.7 seconds on my machine (running from an SSD)
Thank you. The difference can be considered big, because it is almost half the time. I'm also with a SSD.
Still, 1.7 seconds seems too much.
-
Oct 16th, 2018, 09:37 PM
#15
Re: CreateObject("Word.Application") very slow with Word version 16
I tested keeping the Word instance opened but the issue is that the user can close it, when the user closes a document in fact she/he closes the Word window and the instance is terminated, and when I try to reuse it opening a new document I get an error.
Another thing that takes several seconds is when I set the Document object reference to Nothing (at the end).
-
Sep 27th, 2022, 11:22 PM
#16
Registered User
Re: CreateObject("Word.Application") very slow with Word version 16
Originally Posted by Eduardo-
I tested keeping the Word instance opened but the issue is that the user can close it, when the user closes a document in fact she/he closes the Word window and the instance is terminated, and when I try to reuse it opening a new document I get an error.
Another thing that takes several seconds is when I set the Document object reference to Nothing (at the end).
I am also getting the same issue causing considerable problem to the user. Whether your issue is resolved ? If yes, what was the solution. I tried to kill the WINWORD.EXE using TerminateProcess and then setting word object to Nothing, it still getting delayed.
Any advise will be greatly received
Thanks
Sadagopan TS
-
Sep 28th, 2022, 02:08 AM
#17
Re: CreateObject("Word.Application") very slow with Word version 16
Originally Posted by Sadagopan TS
I am also getting the same issue causing considerable problem to the user. Whether your issue is resolved ? If yes, what was the solution. I tried to kill the WINWORD.EXE using TerminateProcess and then setting word object to Nothing, it still getting delayed.
Any advise will be greatly received
Thanks
Sadagopan TS
No... The only workaround is not to start a new instance every time and try to reuse the same for several tasks, when you need to do several consecutive tasks.
I takes several seconds to start.
-
Sep 28th, 2022, 02:46 AM
#18
Re: CreateObject("Word.Application") very slow with Word version 16
I use word and I noticed that the only thing that is fast enough is CheckSpelling.
trying to add grammar will make everything too slow.
also I use it in my "graphical" text-editor for my game. so its not any textbox or any string.
what I do is that I analyze "new/changed" words, so its not continuous check and not the whole text.
also, it will only work during idle. when user is typing the checking is paused. (like 1 second, but its good enough to not create too many calls)
first I initialize it
Set wd = CreateObject("Word.Application")
wd.Options.IgnoreMixedDigits = False
wd.Options.IgnoreUppercase = False
and after that I just call
wd.CheckSpelling(wordtocheck$)
for each word I want checked.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|