Hope that you are all OK .
Sorry to bothering you , but I have a question if you please .
What is the difference between Createobject and Getobject in vba and when can I use each ?
Thank you for your time
Hope that you are all OK .
Sorry to bothering you , but I have a question if you please .
What is the difference between Createobject and Getobject in vba and when can I use each ?
Thank you for your time
Essentially one will create a new instance of the Object, and the other will get a existing instance if it exists.
https://vbaoverall.com/getobject-vs-createobject-vba/
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
Just to add to Minty's comments, GetObject code is usually run first to use an existence instance of e.g. Outlook or Excel if it exists. If not, that triggers error 429 and CreateObject is then run to open a new instance. See https://docs.microsoft.com/en-us/off...bject-behavior
Last edited by isladogs; 03-13-2021 at 11:28 AM. Reason: Corrected link
Thank you for your replay . .
but really i can not know what is the mean of "instance" . .
mean that there is a Ms word installed in the computer ?
or
mean that there is an open word document ?
i try both with Getobject but i got error . . not 429 . .
and what is the relation of adding Ms word reference with all that . .
Thank you for your replay . .Just to add to Minty's comments, GetObject code is usually run first to use an existence instance of e.g. Outlook or Excel if it exists. If not, that triggers error 429 and CreateObject is then run to open a new instance. See http://www.mendipdatasystems.co.uk/c...ace/4594365418
but really i can not know what is the mean of "instance" . .
mean that there is a Ms word installed in the computer ?
or
mean that there is an open word document ?
i try both with Getobject but i got error . . not 429 . .
and what is the relation of adding Ms word reference with all that . .
Can you post the code where you are getting the error?
Show any error numbers and descriptions.
Post 5 was moderated, I'm posting to trigger email notifications.
Apologies. I posted a link to my website in error in post #3. I've now corrected that post.
GetObject is used to automate working with an open Office application such as Excel.
if you use CreateObject instead that would create two open 'instances' of Excel which is usually undesirable..
So the idea is to first test whether e.g. Excel is open using GetObject. If not, error 429 provide a prompt and CreateObject is then used.
Re-check the earlier links in posts 2 & 3 for how this should be coded