VBA Rubberducking

This chat has moved to Discord: discord.gg/MYX9RECenJ
Feb 17, 2022 12:18
Ohh post too late to be edited, but thanks :)
Feb 17, 2022 12:14
Boolean examples postem above with `Not` blowed my mind firstly. But it seems it is just counterintuitive operators precedence problem if I understand correctly.
```
?Not False = Not 1
True
?(Not False) = (Not 1)
False
?Not (False = Not 1)
True
```
Jul 3, 2021 12:25
Write own error handling classes, extensibility library wrapper, modules parser for a few days. And after a lot of sweat, pain and tears buy vbwatchdog finally. My true story... ;)
Apr 20, 2021 08:46
I wanted show some new possibilities using twinBasic on main Excel's internet board in my country, but it seems I must switch to x32 first
Apr 20, 2021 08:43
Just discovered twinBasic thanks to last post on RD blog. Incredible...! The only thing I am a bit disappointed is I cannot test own dll's (unfortunately Office x64 here) :(
Mar 29, 2021 12:31
@MathieuGuindon Ok, maybe in the future :)
Mar 29, 2021 09:19
Hello! Is it possible in Rubberduck to define own autocompletion rules? I mean somethin like: type "pubf", hit enter and I have "Public Function ()" in a result (example like in PHPstorm). Thanks
Feb 13, 2021 10:32
But thanks, maybe in the future I find a way to hack that white color in other panes
Feb 13, 2021 10:30
It's my theme :D reproduced by one well-known theme
Feb 13, 2021 10:30
Feb 13, 2021 10:24
OK, so it seems impossible to change colors without changing excel sheet-cells 'white' look
Feb 13, 2021 10:17
Is there any known 'hack' to change colors in Code Explorer pane (and maybe Properties, Locals)? I am not asking to inverting colors in entire system. I have pretty dark theme in main code window, but this white-backgrounded panes next to it make me sad...
Feb 12, 2021 23:17
Have a nice weekend
Feb 12, 2021 23:16
(Today I made first first full interface-based solution in VBA for my client. I was soooo surprised when it worked after 2 hours coding and a few minutes of debugging :D like Mathieu wrote once propably on the blog- OOP is a rabbit hole and I want to go deeper into this :D)
Feb 12, 2021 23:02
:) Maybe full-fledged... Simple task just to paste table from Excel to Word (template file) bookmark using .PasteExcelTable method, delete table in before next iteration and the bookmark is gone somewhere deleted... So simple work but seems so counter-intuitive for me in Word
Feb 12, 2021 22:56
Word VBA seems so "dirty" to me with its selections... Going there from Excel seems terrifying, just want to complain to someone...
Jan 29, 2021 12:49
My example above was wrong, the test was on empty 'not initialized' table (.ListRows.Count =0 and the comparision was Nothing=Nothing). Nevermind, it's just mysterious implementation of Range. Have a nice weekend!
Jan 29, 2021 11:54
no sense at all for me :D
Jan 29, 2021 11:54
but if I changed .Range to .DataBodyRange it returns true
Jan 29, 2021 11:54
Debug.Print A Is B // false
Jan 29, 2021 11:53
Set A = ThisWorkbook.Sheets(1).ListObjects(1).Range
Set B = ThisWorkbook.Sheets(1).ListObjects(1).Range
Jan 29, 2021 11:53
I made some tests today and still it makes no sense about IS
Jan 28, 2021 23:47
I must read all your comments one more time carefully. It seems like worksheet object has a lot of "additional information" e.g. Cells collections too, that you can refer to, but its behaviour with "Is" is different than Range
Jan 28, 2021 21:34
"a range object has more internal state than the underlying range" Could you write this in simpler english, please? This is very interesting, but unfortunatelly my english isn't very good... Thanks in advance. I am trying to learn about the difference with Range object itself.
Jan 28, 2021 21:15
Maybe yes, but it' quite counter-intuitive that fully qualified Range's behaviour is different from the other objects... But thanks
Jan 28, 2021 21:11
I mean something like this Set ws1=ThisWorkbook.Sheets(1), Set ws2=ThisWorkbook.Sheets(1), ws1 Is ws2 // true
Jan 28, 2021 21:08
But why there are 2 different object ONLY for Range object in this case? E.g. if declaring two different variables ThisWorkbook.Sheets(1) - the Is returns true
Jan 28, 2021 21:06
So another bug/gotcha in our lovely VBA... :D
Jan 28, 2021 21:02
I am not sure if I understand ok: so this strange result of 'Is' is caused by range's default member - .Value? It seems there is no other object in VBA with the same behaviour. Is it the only exception?
Jan 28, 2021 18:56
It seems that the problem with ridiculous result of Is occurs only with Ranges
Jan 28, 2021 18:52
I saw a few threads over the Internet, but no one explained :( Debug.Print ThisWorkbook.Sheets(1).Range("A1") Is ThisWorkbook.Sheets(1).Range("A1") // return false. Maybe someone here knows whats going on Range+Is... :)
Jan 26, 2021 11:25
It's quite strange that on the same Windows+Office settings the same implicit conversion can result in two differents strings. One more reason that implicit conversion is evil. Regards!
Jan 26, 2021 11:24
Just a little fun fact about my question about implicit conversion: when assigning Bool variable to String variable, it seems that another algoritm is used than implemented in VBA.Cstr and can result in regional name (from Windows Regional Settings?). For example False bool value can eval into strings "Falsch" (german) or "Fałsz"(polish) ect instead of just "False".
Jan 21, 2021 18:09
This type of casting seems be undocumented and may results in using Windows Regional Settings names like "Falsch" in German or "Fałsz" in Polish language. When using CStr the result is always predictible and results in "True"/"False" word.
Jan 21, 2021 18:09
If someone have something interesting to add to my little 'bounty' on SO feel free stackoverflow.com/questions/46565072/… it is about implicit conversions in VBA and I am interested especially what happend when you assign bool to string type variable. Most discussion's part is in comments.
Jan 11, 2021 15:27
very interesting, thanks one more time, I'd do some test on that case
Jan 11, 2021 15:20
Haha! I've supposed that it is something with def value! Thanks a lot! I read every rubberduck news multiple times. Even my wife is sometimes angry of me becasue of that! :)
Jan 11, 2021 15:16
But why I need to use empty brackets to reference to first or second cell in the object such in example above [a4:a5]()(1) works and [a4:a5](1) - compile error
Jan 11, 2021 15:14
Hehe sorry for that! :D
Jan 11, 2021 15:13
Hi! I've just saw quite strange code for me - a reference to a cell in evaluated range: [a4:a5]()(1). Without empty parantheses [a4:a5](1) there is a syntax error (wrong number of arguments or invalid property assigment). What does really empty round brackets () do in this case? If the answer isn't obvious I would ask on SO. Thanks
Dec 18, 2020 12:55
@MathieuGuindon Incredible, I've read the article few days ago and didn't realise that I can use Sync Project as a solution for that problem. Thanks a lot! :)
Dec 18, 2020 11:42
(I use Office 2016 and my clients often 2010-2013 version)
Dec 18, 2020 11:38
Is any working "VBA decompiler" for Office x64 bit? For a some of my clients I must use full qualification e.g. VBA.Len insted Len, Dim coll As VBA.Collection instead Dim coll As Collection etc. If I use VBA methods without "VBA." it throws compile error on some PCs. I've read it's a know issue and "decompiling" is an option. Thanks!
Dec 10, 2020 14:15
Yes, you're right :) @FreeMan gave me some idea- I would export entire project to my Library "real" hard drive folder with VCS implemented. I just read that .gitignore can be set "reverse" to ignore all files except given list, so I would set the list of my Library classes. And add some code to clean the folder from project-linded files using powershell or other automatic script. If it would be an option to export one RD "folder", it would be more simple, but thanks for all above sugestions
Dec 10, 2020 14:01
My Library almost 100% vanilla VBA, because performance for me is on the second place, the reliable working is priority. I send my files and should work without any additional work except enabling macros (and no trust VBA Project Object Model changes).
Dec 10, 2020 14:01
@Freeflow I thought about this. But without external reference I found things simplier. Some of my Excel workbooks are used by 30 people, I would not to use TeamViever to set the references on each PC... I even use late binding to avoid problems with e.g. Word library versions.
Dec 10, 2020 13:40
but I need to think about it to improve my work, it seems not to be the best solution :)
Dec 10, 2020 13:40
I know my workflow isn't best, I am still learning to become programmer. When I start new project first thing for me is to import my Library classes to project (newest version from hard drive). While working on project I often get an idea to add new useful method to one or few my Library's class, or just fix something. So I make changes in the class in current project, and after all I export entire project, later choose library classes to overwrite previous version on hard drive.
Dec 10, 2020 13:20
So unfortunatelly it's not possible at the time. My library is still growing, it contains about 20 classes, a few interfaces (due separate classes for Windows and Mac in some cases), and few userforms. I often make changes to my Library while working on specific project, so exporting entire project is mixing my library files with other current-project classes and modules. Maybe in the future :) thanks for the answer
Dec 10, 2020 10:36
Hello! :) Is it possible to select in RD Code Explorer specific "folder" and export only classes in that folder to .cls and .frm files? I am building my own multiplatform VBA library, and it would help me a lot. I only see built in export single class method and RD option to export entire project.