« first day (138 days earlier)      last day (3042 days later) » 

02:05
@RubberDuck any idea how to assign a keyboard shortcut to a VBIDE custom commandbar button?
No. I've not done that.
@Mat Application.OnKey ?
3
Q: Keyboard Shortcuts in Excel Menu CommandBar

Frank SeifertThe code below adds a menu item Custom1 right before New.... How can I get the keyboard shortcut assigned to CodeCustom1 (via Application.OnKey) to appear nicely right-aligned with Ctrl+N? Sub menuItem_Create() With CommandBars("Worksheet menu bar").Controls("File") .Controls.Add(Type:=...

works, ..but only from Excel - the IDE doesn't pick it up
^^ bad shot, lol I had removed the Application before the .OnKey
Does this help?
Set NewMenuItem = Toolsmenu.Controls.Add (Type:=msoControlButton)
With NewMenuItem
.Caption = "My special button"
.ShortcutText = "Alt+R"
.OnAction = "Macro1"
End With

Application.MacroOptions Macro:="Macro1", HasShortcutKey:=True, ShortcutKey:="R"
No. Because application refers to excel...
02:20
Application is the host app... I ..that
bah, I can live without keyboard shortcuts in the IDE.. would be nice to figure that out though
BTW the VBA code there is just to see pick the FaceID's - I'm actually doing this in C#, I'm rewriting my Assert class as a COM-visible ...hmm can I expose a static class to COM? so many things I've never done before....
Well... Stumbled across a MS tutorial on VBIDE... msdn.microsoft.com/en-us/library/aa260355(v=vs.60).aspx
Not helpful a bit.
02:43
> COM does not support static methods.
Lame. I'm not finding anything on keyboard shortcuts either. It really sucks that the IDE isn't a "first class citizen"
yeah
well for the static Assert class I think I'll make a "New test class" menu, that will add a class module and add code to create the AssertClass instance, conveniently called Assert - how's that?
(with a stub TestMethod1 test method)
More or less what I did.
I need to rewrite it though. Really just not happy with it as it is.
02:59
C#?
VBA. I ditched the COM add-in for some now unknown reason.
I know it had to do with the IDE being a second class citizen though...
Ahhhh. It's because I needed to cast the application object to get to the VBE object, but I wanted to use the add-in across multiple apps.
Since I had to create multiple add ins anyway, I just wrote it in vba.
isn't Application the ...IDE?
        public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
        {
            _application = (IDE)Application;
            CreateTestMenu();
        }
haven't tried it yet
using IDE = Microsoft.Vbe.Interop.VBE;
I had the genius idea of calling my namespace RetailCoder.VBE ...so VBE is ambiguous :/
Application is the host app. Excel, Access, Word, etc.
makes sense
try 'em all until you get a non-null value?
The only thing I can think to do is keep trying to cast it until one sticks. That^
Then you just register the one add-in for all the available apps. Voila! Universal IDE add-in. I need to try it.
03:11
ugh.. VS Express doesn't have a "start application" option in the project properties / debug tab - I can't F5-start Excel
Start process maybe?
I only have "Command line arguments" and "working directory" start options
in VS Pro you get to specify an application to launch .. that ^^^
I'm out Mug. Keep me posted on how you make out.
03:14
'night!
ah
            _application = ((Excel)Application).VBE;
using Excel = Microsoft.Office.Interop.Excel.Application;
 
1 hour later…
04:31
ugh
clue anyone?
 
3 hours later…
07:09
@Mat'sMug when you right click the Solution in VS - select Properties, on the left hand side there is a Debug tab and you can select the external application there
 
4 hours later…
10:46
Not in Express2014
11:22
*2013
11:41
@Mat'sMug oh sorry then I didn't know :O
11:57
Ahh @Mat I've seen that and fixed it, but I can't remember what caused that. It was a few months ago.
side comment: shouldn't using Excel = Microsoft.Office.Interop.Excel.Application; be using Excel = Microsoft.Office.Interop.Excel; ?
12:49
That ^ might be what's wrong.
13:19
Nope. I'm not using the Excel object model for anything other than accessing the Application class; that using aliases the Excel.Application class with Excel as a convenient shortcut. If that's the class I need to cast the incoming Application parameter to, all is good. You know you can use using to alias a class, not just a namespace :)
14:14
@Mat'sMug I did not know that actually. That's pretty cool.
14:35
@Mat'sMug every time I go to this chatroom I want to close that popup. Every. Time...
2
15:01
@Mat'sMug I may have missed something here but it seems to me like if you were trying to cast Microsoft.Vbe.Interop.Vbe to Microsoft.Office.Interop.Excel.Applicaton?
what type is your _application?
@Mat'sMug Express 2014? ??? I just got 2013 on my computer at home
15:14
@Malachi *2013
LOL
Don't tease me like that @Mug (@Mat'sMug)
15:29
Oh I am literally 1 letter away from making this happen

Dim c as Class1
set c = Class1("wtf", "am", "i", "doing")
2
I'm quite intrigued by this :)
basically I made a static class first and made one LET property the default member
that in theory should allow Class1 = "something"
15:34
but the Set is needed so i've changed it to be a SET property instead
I end up using "Creation data" for all my "constructors" and then have validation methods that they were created correclty
it's fugly that's for sure
Hi all - thanks for the invite mehow :)
2
15:48
@Blackhawk no problem and welcome! :)
0
Q: Insert variable number of rows

User406160In the excel vba sub below i need to insert the number of rows equal to variable j after row equal to k. So if J=17 and k=2 then i want 17 empty rows after row 2. The code below is inserting the empty rows (j=17) however it is starting on row 17. How can i start on row equal k? sub stuck() Dim w...

^ off-topic
heh I don't even have enough rep to downvote questions
I need to answer more
2
I need more time to be able to spend some time on an answer
Guess I'm hosed :)
16:06
@Blackhawk Hey there!
16:59
@vba4all You have my interest and I am looking forward to the blog post.
17:54
@vba4all is the setter blocked after instance is "constructed"? Makes a weird/confusing syntax for VBA IMO. #partypooper
 
1 hour later…
19:03
0
Q: StringBuilder in VBA

BlackhawkIn the process of trying to build a serializable data structure, I found myself building large strings, which gets very slow because VBA copies a string every time concatenation is performed. To alleviate this, referring to Dynamic Array and Java's StringBuilder interface, I cobbled together a u...

I have a JSON parser I'd love advice on - especially if @Mat'sMug can give me pointers on coding style (I'm generally the only consumer of my code, so I get extremely lazy), but as my first gentle introduction to CodeReview, I posted a StringBuilder class that's used by the JSON parser.
Just upvoted that StringBuilder - I like it a lot!
Go ahead, post it! :)
Welcome to Code Review BTW!
Thanks! Didn't know I'd been missing the party :P
2
@StackExchange That's some heavy stuff. Good looking question @Blackhawk.
@Blackhawk you've left the test results for the curious to find out? ;)
(I'll run that tonight for sure!)
19:18
It's a pretty stark contrast ;)
Pimping an SO answer
0
A: Change VBA coding with VBA Coding

RubberDuckFirst, you need to add a reference to the Microsoft Visual Basic for Applications Extensibility 5.3 library. Click Tools>>References>> Microsoft Visual Basic for Applications Extensibility 5.3 Then you need to open the workbook containing the module you want to update. This means that you c...

do we have a feed for SO questions here?
@Mat'sMug No... I wasn't able to figure out a good search query. I'd prefer not to see all the garbage questions.
And there's a lot of them for on SO.
probably a good call
aren't VBA characters ANSI?
19:27
I think so. Why?
ReDim m_stringBuffer(0 To (DEFAULT_CAPACITY * 2) - 1) 'Each unicode character is 2 bytes
bah, ?lenb("a") outputs 2, so whatever
According to the VBA Language Spec, they are "Sequences of 16-bit binary encoded Unicode code points."
2
Anybody have time to verify this claim?
I corrected the code so its doing what i want. Now where can i improve? — User406160 5 mins ago
@Blackhawk Annnnndddddddd bookmarked.
=)
hmm I think it gets confusing because the IDE itself only supports ANSI strings
what does derp mean?
On Error GoTo derp
2
19:44
LOL oops :P That was a temporary bit of error handling to find the cause of a very specific issue which has since been resolved...
Incidentally, here is a fantastic reference on VBA Strings
2
too late, it's reviewed now! :)
Well thanks! That's the version that's being used in other things, so it's a good heads up to remove the "derp" from all of them.
and posted!
bbl
(gotta work)
20:00
Haha comment of the day
ha - That's insane!!! High five — Webb 1 min ago
20:29
_GN_          ' BIG FLAMING HACK WITH A BIG FLAMING SIDE EFFECT HERE. I'm sorry.
I'm sorry too past me ^
Ahaha! Code comment apologies to future selves are the best :)
@RubberDuck that was pre-CR you? ;)
@Mat'sMug Maybe, maybe not. There's seriously no other way to do it.
The comment is ... appropriate.
lol
@Blackhawk like this:
Private Type TLogManager
    Formatter As ILogMessageFormatter
    Loggers As New Dictionary
End Type

Private this As TLogManager
Public Property Get Formatter() As ILogMessageFormatter
    Set Formatter = this.Formatter
End Property

Public Property Set Formatter(ByVal value As ILogMessageFormatter)
    Set this.Formatter = value
End Property
(from this post)
I'm a convert ^
Took me a while to embrace it, but I'll not go back.
20:42
maybe it's just .net that's rubbed off on my VBA coder side, but I like that all property Let/Set procedures consistently take a value parameter.
and as much as I love prefixing C# private fields with an underscore, I love how this eliminates name clashes in VBA
20:55
That's pretty spiffy!
And if my class only has value types, this makes it instantly serializable!
how do you serialize in VBA? did I miss something?
If you have a Type, you can write it and read it to/from a file using Put and Get
It allows you to do some low level interaction with binary file types, which is pretty cool
21:12
hmm very interesting!
In fact, I'll have to post the TAR classes I wrote up on CR - it's a limited subset of the Tape ARchive specification that generates container files you can actually open with WinZip. It's a good example of the Type export/import behavior
that's... utterly cool! ...except the WinZip part ;)
21:33
@Mat'sMug Then use 7zip. Because that is awesome.
I don't dare dip that close to the metal.
isn't it (.zip compression)... built into Windows?
@Mat'sMug It was built into xp. Not sure if they still support it or not.
In fact, I think they don't. I went out and got 7 zip for my win 8 machine.
zip compression is built into .net, I never needed any 3rd-party tool to open up zipped files on my Win8/8.1 box...
TTGH - later guys!
21:49
Seeya!
@Blackhawk where were you yesterday when I scored a +150 bounty and closed the day at 25 points short of rep cap! ;)
(kidding)
I'm GoTo derp
Heh, went back and saw it :) Incidentally, I'm gonna have to try the unit test thingy of awesomeness
I'm re-implementing it in C#, ..if I can only get the VBIDE add-in to load...
20 hours ago, by Mat's Mug
user image
and then
17 hours ago, by Mat's Mug
user image
ok gone (will try to get it to work tonight!)
Dang :(
 
2 hours later…
23:56
Anyone have any thoughts about this?
I've done some digging around and the answer is no. You can not set a default value in the signature line because it expects a constant expression. All you can do is check to see if the variant is missing. I suppose you could fake an overload with a second function, but that seems convoluted. — RubberDuck 1 min ago
OP wants to set a default value for an optional array parameter.
Sounds right

« first day (138 days earlier)      last day (3042 days later) »