View Single Post
  #4  
Old March 24th 09, 01:32 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Script w/relative path that sends absolute path to a folder to the clipboard?

Nothing to do with Outlook code.

Using Win32 API calls code would look like this:

Public Declare Function SHGetFolderPath Lib "shfolder.dll" _
Alias "SHGetFolderPathA" (ByVal hwndOwner As Long, ByVal nFolder As Long,
_
ByVal hToken As Long, ByVal dwReserved As Long, ByVal lpszPath As String)
As Long

retVal = SHGetFolderPath(0&, CSIDL_LOCAL_APPDATA Or CSIDL_FLAG_CREATE, _
0&, SHGFP_TYPE_CURRENT, strLocalSettings)

But you can't use Win32 API calls from VBScript code.

Using VBS there isn't a way that I know of to get to appData directly.
What you can do is to use the registry functions in Windows Scripting to
read a registry location that should point to appData.

The location to look at is
HKCU\Software\Microsoft\Windows\CurrentVersion\Exp lorer\Shell
Folders\AppData. That has a string value pointing to appData, you can take
that and append "\Microsoft\Stationery" to it.

The Windows scripting method to use would be WshShell.RegRead, something
like this:

Dim WshShell
Dim appDataPath
Dim strPath

strPath = _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Ex plorer\Shell
Folders\AppData"

Set WshShell = CreateObject("WScript.Shell")

appDataPath = WshShell.RegRead(strPath)
appDataPath = appDataPath & "\Microsoft\Stationery"

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"StargateFan" wrote in message
...
On Fri, 20 Mar 2009 06:51:08 -0700 (PDT),
wrote:

[snip]

In AutoIt, to open up a folder with a relative path, this is the
syntax, in an effort to illustrate the type of scripting in vb that
would be ideal to achieve:



ShellExecute(@UserProfileDir & "\Application Data\Microsoft
\Stationery", "", "", "open", @SW_MAXIMIZE)


[snip]

Can something like this be done in Outlook, pls?


Ads