Category Archives: MS Word

VBA – Storing Information In The Registry

How can we store information:

  • Settings
  • Preferences
  • Object States and positions

for a VBA solution, whether that be an Access database, Excel workbook, Word Document …?

What about storing the information in the registry!

That’s the subject I would like to broach in this article.

Continue reading

Microsoft Office – Adding a Progress Bar

So a few days ago I published an article about using conditional formatting to create a progress bar in an Excel Worksheet to display, in real-time, the progress of some process to your users.  You can read all the details at:

That said, I then pushed a little further to create a reusable progress bar utilizing a Userform that could be incorporated within any Microsoft Office application and that works as a pop-up overlay to display the progress of a process.

Continue reading

VBA – FSO Files, Folders, Drives and More

Over the years, I’ve posted punctual articles relating to individual FSO solutions:

and many, many more.

Today, I thought I’d provide you with a complete breakdown of the File System Object (FSO) most common functions to give you a proper overview of just how useful it can be to you when you need to interact with File, Folders and more.

There’s a lot of content to this article so I’ve broken it up into the following sections:

Let dive in!

Continue reading

VBA – Determine the Current Ribbon State and Change It

I’ve shown you the way you can determine and then Expand and Collapse the Ribbon using UIAutomation in my previous articles:

and I prefer that approach for a couple reason, but also because it is part of a larger code base I have developed.

but I also am aware that sometimes we want a simple solution. 

So in this article I thought I’d show you a pure VBA (no extra references required) approach to do the same things I achieved with UIAutomation.

Continue reading

VBA – UIAutomation – Minimize and Maximize the Office Ribbon

Spring

Just a quick post today and sort of a Part 2 to my previous post:

I thought to myself, now that I can easily and reliably determine if the Ribbon is Expanded or Collapse, wouldn’t it be useful if I could change that (thinking about changing tab and clicking on command – coming soon!).

And so, I started to do some digging and testing.

I was hung up on UIAutomation, and this was a mistake in this instance!  Sadly, from what I could determine, UIAutomation does not appear to provide any means to perform mouse click per se.  You can retrieve mouse coordinates and get into APIs, but I didn’t want any of that.

I knew we could use

CommandBars.ExecuteMso "MinimizeRibbon"

to minimize the Ribbon, but to maximize it, people often recommend and resort to using things like:

SendKeys "^{F1}", False

but SendKeys are dangerous and should be avoided!

Then, I had a mishap, I ran the minimize command when the Ribbon was already Collapsed, and it Expanded, say what?!  And so, the simplest solution ever was created, use he minimize command to both Collapse and Expand the Ribbon.

Continue reading

VBA – UIAutomation – Is The MS Office Ribbon Expanded or Collapse?

Measuring Tape

I’ve been playing around a lot with the UIAutomation library recently and wanted to see if it would be possible to check the status of the Ribbon.

Traditionally, to check if the Ribbon was Expanded or Collapsed, people rely on the height, but I don’t like that because I have no clue if that value might vary from PC to PC, or Edition to Edition, or if Microsoft might randomly change it one day down the road for some reason.  So I decided to explore this a little using UIAutomation.

Continue reading

VBA – Padding a String To A Desired Length

Pad String Left or Right

Ever needed to control the length of a string to align content and needed to ‘pad’ the string with spaces?!

This can be a common need when generating text files, populating Textboxes, …

VBA String Padding

Today, I thought I’d share a very simple solution that can be used to pad a string from either side.

Continue reading

VBA – Expand Short File or Path

Ok, I’ll admit it, expanding a Short format File or Directory Path is a niche ask, but I recently required this ability and so I thought I’d share my solution in case anyone else was faced with this need.

Where did my need come from exactly?

Well, I was setting a Reference dynamically and the technique utilized a registry value which was in Short format. I then wanted to validate, but couldn’t because the Reference Path had been expanded to Long format. Thus, I needed that same ability so I could compare apples with apples.

Continue reading

Developing Project Requirements and Specifications

Project Talk

I know, everyone’s favorite subject!

I also know many developers skip over this step. (Don’t be one of those people!)

What Are Requirements

Requirements document what is needed and should not explain how it will be accomplished.  It is a list of wants and needs.

What exactly is it that your client needs.
What is expected of you as a developer.

This is typically the responsibility of the client to create, but I have helped numerous clients define these while developing Specifications to ensure I was accurately perceiving their projects accurately.

Don’t just take verbal requirements.  Put them down in writing, even an e-mail, and get the client to acknowledge them.

What Are Specifications

In the simplest terms, specifications explain how you will attain the requirements.

What is it that your solution will do and how it will be composed to do so.

This document is created by the developer to explain to the client how they propose to address their Requirements.  Some aspects will be simply repeating requirements (in a reworded way), this is normal.
Continue reading