Questions tagged [vba]

27 questions
19
votes
7 answers

Team member questioning moving from VBA to C#

Background Last year, I was asked to create a tool to be used for business planning for around 10 users. This was done on behalf of another IT team who "sub-contracted" the work to me, and due to the project deadlines being a little unplanned on…
i_saw_drones
  • 309
  • 1
  • 2
  • 7
14
votes
4 answers

Why does Microsoft still ship VBA within Office products, instead of integrating .NET directly?

I know that it's possible to call .NET code from your VBA code, but why does VBA continue to exist? The only reason I can think about is legacy. I just had to sort a Scripting.Dictionary and the amount of code needed was frightening. The IDE looks…
Kiril
  • 529
  • 2
  • 4
  • 11
11
votes
0 answers

Implement FBP / Dataflow programming in VBA?

Intrigued by Flow Based Programming a la J Paul Morrison. I wonder if one can implement FBP in Excel/VBA. I searched quite a bit for a Basic-Lang FBP implementation to no avail. I've looked at some FBP implementation details in Python but I'm not…
klausnrooster
  • 231
  • 1
  • 6
9
votes
5 answers

How to refer to ByRef and ByVal in a dropdown label?

The MSDN page on ByRef and ByVal keywords isn't very helpful; unless I somehow skipped it, they're simply being referred to as "keywords" everywhere. One of the main contributors of the Rubberduck project is working on a very cool Encapsulate Field…
Mathieu Guindon
  • 1,720
  • 16
  • 33
8
votes
6 answers

performance versus reusability

How can I write functions that are reusable without sacrificing performance? I am repeatedly coming up against the situation where I want to write a function in a way that makes it reusable (e.g. it makes no assumptions about the data environment)…
Caltor
  • 189
  • 5
8
votes
2 answers

Why does VBA / VBScript require "Set" prefix

When I set a variable to an object in VBA / VBScript, I always need to prefix the statement with "Set" such as: Set Dict = CreateObject("Scripting.Dictionary") If I set a variable to a primitive or array value, I have to omit the "Set" such as: Num…
neelsg
  • 473
  • 5
  • 13
4
votes
1 answer

PowerShell performance when running Excel macros

I run on a daily basis a set of VBA-rich Excel files. Most of them include MS Office application cross-talk, but also employ third-party applications and MySQL. Due to the fact of running those files in a specific order and at a specific time of day…
Oskar_U
  • 151
  • 5
4
votes
1 answer

Block Scoped and Function Scoped Languages

I've noticed that some languages like C, C++, Java, Perl, and .NET Visual Basic have "block" scoping which means that a variable will only be defined within the specific code block it was declared in. For example (C++): if (true) { int x =…
3
votes
1 answer

VBA Outlook: quickly find subfolder

I have the following structure in my Outlook Public Folders. -Public Folders --1001_RandomProject --1002_AnotherProject --1003_Yetanotherproject ... and so on, basically there's a couple of thousand(!) subfolders each corresponding to a project and…
Sam
  • 143
  • 5
3
votes
1 answer

Implementing a Username Class

I am attempting to encapsulate several features about a user in a single class. Although the main use for this class would be to initialize it once and never have to call set any variables again, I would like this class to be scalable to be called…
Elias
  • 193
  • 1
  • 6
2
votes
4 answers

Conditional vs Logical Testing

I would like to get your code thought and views on using conditional vs logical testing. For example: To test the conditions of truthness of all of the following variables, their currect status is as follows: a= True b= True c= True d= True e=…
2
votes
2 answers

Can I really make python work with VBA

I'm a heavy VBA user that when has the chance to do a little project in python it's like going from hell to haven when it comes to programming itself. Still, I know that my users want reports in excel (for good reasons) and I'm just not ready to…
BuckTurgidson
  • 31
  • 1
  • 4
2
votes
1 answer

Why would a program allow an object to be initialized when it doesn't support all methods/properties of the interface type it was defined as?

I'm under the impression that an object MUST support all methods/properties upon being initialized or else the program will create an error. However, if you see below I am defining 2 variables (doc and el) as htmldocuments. Thus any object…
apdm
  • 121
  • 2
2
votes
2 answers

Managing sets of configuration data for an Excel/VBA program

I have two versions of an "Excel-Tool", i.e. a spreadsheet with a lot of vba code. Lets say, this tool is used to monitor two facilities. Both facilities differ in minor aspects. That means, I have magic numbers in both versions to set the correct…
Oliver
  • 133
  • 1
  • 6
2
votes
1 answer

Should I use Strategy Pattern for this task?

I'm setting up a data validator that will iterate through the rows of a spreadsheet, and for each column, perform a validation check. I was thinking that this might be an appropriate task for the Strategy Pattern as follows: interface…
sigil
  • 363
  • 1
  • 9
1
2