Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #18  
Old 06-19-2014, 05:29 PM
whatsup whatsup is offline Slow "comparison/replace" script Windows 7 64bit Slow "comparison/replace" script Office 2010 32bit
Competent Performer
 
Join Date: May 2014
Posts: 137
whatsup will become famous soon enough
Default

Quote:
To be honest, its not really any different from if the throw error switch is false. This is because the error is "handled".
Now I do see it too - you're right. Nice idea postboning the error-exit. That seems now allright to me. Nonetheless, somehow it's not the right way to go. It still leaves to much room to guessing whether memory is freed from the particular object or not...

Im still trying to read from the pointers. At least I got it working the way, that the function works when called from the macro creating the object. My mistake was, not destroying OTemp. That I do now with one more line:
Code:
Function ObjectFromPointer(lPtr As Long) As Object
     Dim oTemp As Object
     
     Mem_Copy oTemp, lPtr, 4
     Set ObjectFromPointer = oTemp
     Mem_Copy oTemp, 0&, 4
End Function
That way it can be used in the first macro, proofing that if the pointer contains an object, it can be copied to an object (remember this words):
Code:
 
 Sub ExampleForObject2()
Dim objRange As Object
     
Set objRange = Sheets(1).Range("A1")
    
lng_ObjPtr = ObjPtr(objRange)
    
If ObjectFromPointer(lng_ObjPtr) Is Nothing Then
    MsgBox "Object is Nothing"
Else
    MsgBox "Object exists"
End If
 'Set objRange = Nothing
    
End Sub
That runs without any error. Now let's go to the check afterwards:
Code:
Sub ObjectIsGone2()
If ObjectFromPointer(lng_ObjPtr) Is Nothing Then
    MsgBox "Object is Nothing"
Else
    MsgBox "Object exists"
End If
 End Sub
Now again that will make excel crash!!
Crashing at the point Mem_Copy oTemp, lPtr, 4 in the function. Even with changing oTemp declared as Variant, it can't be done. So what else can be behind the pointer???
There's a chance that the address get's occupied of something else, but what can that be, you can't address to a variant?
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wierd "script code" in a downloaded .doc file CNBarnes Word 2 10-18-2012 02:07 AM
Slow "comparison/replace" script replace data from variable with "sub and super script" from excel to word by vba krishnaoptif Word VBA 9 06-22-2012 05:08 AM
Slow "comparison/replace" script How to choose a "List" for certain "Heading" from "Modify" tool? Jamal NUMAN Word 2 07-03-2011 03:11 AM
Rules and Alerts: "run a script"? discountvc Outlook 0 06-15-2010 07:36 AM
An "error has occurred in the script on this page" decann Outlook 8 09-03-2009 08:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft