Archive for the ‘Windows API’ Category.
Hi everyone,
The release date of Office 2010 is closing in and with this new version we’ll have a new programming challenge. Office 2010 comes in a 32 bit and a 64 bit version.
Especially API function declarations need to be adjusted for the 64 bit environment.
We’ll have to change a declaration like this one:
Private [...]
I don’t know why there’s not an easier way to open attachments from an email I’m viewing, but there’s not. I made stole some VBA code to do the job.
First, I borrowed JP’s code to Open Any Email Attachment From Outlook. Then I changed a few things. I only wanted to open [...]
VBA has an Environ function. To get a list of all the Environ variables you can see, you can use the method at VBA Express. I use the USERPROFILE argument like this
Public Function MyDocsPath() As String
MyDocsPath = Environ$("USERPROFILE") & "\My Documents\"
End Function
You can also use the Windows [...]
Sometimes I find myself copy-pasting between Excel and another application.
In this example, I have a table of three columns: First Name, Last Name, Birth Date.
My external application has 3 text boxes, one for each of those values.
I can’t just copy the 3 cells from Excel and paste them to my App, because they would all [...]
I tried to use EnableCancelKey to allow myself to stop the music and still make the appropriate API calls to reset the midi out. It didn’t work so well for me. Here’s another way.
I created two global variables. One to determine whether the procedure was already running and one to determine if [...]
The EnableCancelKey property of the Application object determines what will happen when a user interrupts your code. Users can interrupt code by pressing Esc or Cntl+Break. EnableCancelKey has three possible settings:
xlDisable - Prevents the user from interrupting. I’ve never used this and can’t think of why I ever would.
xlInterrupt - Normal operation. [...]
I found some code that uses API functions to play MIDI music at a French site. I adapted the code so it's easy to use. Copy the code below and paste it into a VBA module.
Option Explicit
Private Declare Function midiOutOpen Lib "winmm.dll" _
(lphMidiOut As Long, _
ByVal uDeviceID As Long, _
[...]
Here’s what my (partially obfuscated) desktop looks like:
I put information I need on my desktop so I’m a Windows+M key combination away from what I need. The Excel file sits in my XLStart directory so the calendar gets updated every day.
VBA from Excel to Desktop
In the Workbook_Open event, I have
Private Sub Workbook_Open()
[...]