Outlook macro to set location
March 31, 2009 5:22 PM   Subscribe

Outlook Macro Filter: I'm limping my way through creating VBA macro for use in OL07. Be my crutch.

This macro will be called from a button on the toolbar of an open, unsaved meeting invite, and would just append some static text (my conf bridge info) to the current contents of the Location field (there might be meeting room info in there already). This is basically what i've got:

meetingRequest.Location = "800-555-1234 / ID: 1234 / PW: 1234"

If that did work, it would replace, and not append. How do I append, and how do I affect a field on the current form?

Usually Google is my BFF for examples or guidance, but i'm only finding code samples for creating new invites on the fly, and saving them, which, to me is more work. What I am seeing is that all of the code samples I am finding have DIMs and SETs for creating new objects.

Is there a secret to having the macro act on a field in the active object? Do I need DIMs and SETs and whatnots? Can I append? Or am i just missing the whole concept of Macros and VBA?

IANACM, btw.
posted by tdischino to Computers & Internet (3 answers total)
 
Best answer: Here's a snippet that uses the ActiveInspector object to refer to the open calendar item.
Sub updateLocation()


    Dim myItem As Object

    Set myItem = Application.ActiveInspector.CurrentItem

     myItem.Location = myItem.Location & " 800-555-1234 / ID: 1234 / PW: 1234"

End Sub
'myItem' is how we'll refer to the open appointment window. We then use the set command to say "Call the currently open appointment window myItem." Then we say "take the existing 'location' field and append a string that includes a space followed by the dial-in info to the end of it.


This tiny sub does not handle errors (e.g., no appointment or an email item is open instead of a calendar item).
posted by i love cheese at 6:33 PM on March 31, 2009


Oh, and if you want a single line, try the following (all one one line):
Application.ActiveInspector.CurrentItem.Location = Application.ActiveInspector.CurrentItem.Location & " 800-555-1234 / ID: 1234 / PW: 1234"

posted by i love cheese at 8:39 PM on March 31, 2009


Response by poster: Works great, as long as my cursor is not in the Location field. Thanks for the heads up on the ActiveInspector.
posted by tdischino at 11:30 AM on April 1, 2009


« Older Library school with an English MA: should I even...   |   Where do you "game" in the UK? Newer »
This thread is closed to new comments.