Skip to main content
Sancarn's user avatar
Sancarn's user avatar
Sancarn's user avatar
Sancarn
  • Member for 5 years, 10 months
  • Last seen this week
comment
Simulating Objects with Collections in VBA
An alternative could be having GregModule as an addin. I.E. GregModule.xlam. You can very easily check if an addin is loaded, so this might be the best bet among all of them. Though you wouldn't be able to get intellisense without early binding so maybe not.
comment
Simulating Objects with Collections in VBA
@Greg If you're using VBE library, yes you need to enable usage. However if you're using the type library you can do this directly in VBA with no settings applied (although without libraries it would likely be quite involved). stdCOM has partial implementation for this, and may give you some idea as to how you might do it. Otherwise vbInvoke above shows it very well. Depends how confident you are in low level though. A XLL is certainly the easiest way. A dll will require registration with regsvr so not sure how good that'd be.
comment
Simulating Objects with Collections in VBA
"you would need to remove Option Explicit" Indeed, I often avoid using Option Explicit for this specific reason. I quite often use if isObject(stdError) then ... else .... The only other option in my mind is to scan the VBAProject typelib to see if the class exists by name. Greedo has an example of this for vbInvoke
comment
Search through all the sub-folders in a given folder for files
Oooo that's a pretty nice way of making a timer which should be retained across new application instances too... 🤔
comment
Search through all the sub-folders in a given folder for files
Off topic but it's just occurred to me that you can use PQ to query SharePoint data, so making such a VBA library to query SharePoint Online would be pretty useful. Otherwise you're stuck trying to authenticate using the REST API which is a nightmare in my experience.
awarded
answered
Loading…
comment
Safe Windows API Timers for Excel
@Greedo "But maybe Sancarn is talking about a single App Instance being unlocked in-place which isn't the use-case in your remote workbook" - exactly that! I totally forgot that a new app was being created here x)
comment
Safe Windows API Timers for Excel
@CristianBuse " I never needed to open the macro security. Once the registry is changed, any new instance..." - Of course! I totally forgot you were creating a new instance of the application. Anyhow, getting some sort of stable timer with as few dependencies as possible is still useful, even if you did give up, so I wouldn't delete the thread/github, perhaps public archive though :)
comment
Safe Windows API Timers for Excel
"... assembly but it does not work at all" - It only works in Userforms. I too had the same issue as yourself initially 😅. Something to bear in mind is for EnableOfficeVBOM - I believe in some version including mine, you have to open the macro security in order for Excel to open/register that VBOM is now enabled. Alternatively, would it be better to use SaveCopyAs()?
comment
"Sudo Mode" in VBA to Let UDFs Modify Workbook
Lol, funky way of calling by pointer :P I think I'd generally prefer DispInvokeFunc though to invoke the function, though i suppose this also has benefits when vba disconnects?
comment
"Sudo Mode" in VBA to Let UDFs Modify Workbook
Not surprised that my code can cause infinite loops, nor the original. Definitely worth noting though :) I think you could probably use Range_SetValue(), but just have to be very careful about when you do use it. Interesting about the ¬ character. I've made a few highlighters in the past and pretty sure that character wasn't included. Good to know :)
comment
"Sudo Mode" in VBA to Let UDFs Modify Workbook
@CristianBuse Thanks for sending that, I never knew about this, makes total sense though! Very cool.
comment
"Sudo Mode" in VBA to Let UDFs Modify Workbook
> "if state is lost due to using End or pressing the IDE Stop button then nothing can help there." ==> Not totally true that. If you use an Excel object like a worksheet you can theoretically detect loss of state using Application.OnTime loop, though it's pretty nasty... xD
comment
"Sudo Mode" in VBA to Let UDFs Modify Workbook
Quite right! Or error if events aren't enabled... I'm not sure what's best here... If events are explicitly turned off there is usually a reason...Lternativelg putting it into the create method of sudo class.
answered
Loading…
comment
"Sudo Mode" in VBA to Let UDFs Modify Workbook
Thanks for letting us know that Application.Run fails on Mac. Testing on my own Mac which uses Excel for Mac 2011, this doesn't crash for me. However Application.Run "Test()" runs the Test macro twice, where as Application.Run "Test" only calls the function once, as required. So it may be worth removing the brackets from your call...
comment
Private VBA Class Initializer called from Factory #2
This is really cool, am quite amazed this is doable. Never knew it was part of your memory module either!
comment
Low Level VBA Hacking - making Private functions Public
I'd suggest changing Find(ByVal name As String) As TypeInfo declaration to Find(ByVal callback as stdICallable) as TypeInfo and use something like stdLambda: col.find(stdLambda.Create("$1.Name = ""Something""")). Regardless thanks so much for posting this code review! Looks great!!
comment
Low Level VBA Hacking - making Private functions Public
Beyond cool :D I've wanted to do this for a fair while. Finally we can move away from Application.Run()... My stdCallback class could definitely benefit from this!