Script w/relative path that sends absolute path to a folder to theclipboard?

  • Thread starter StargateFanNotAtHome
  • Start date
S

StargateFanNotAtHome

I carry around my Outlook files with me on my USB flash drive, these
include the outcmd.dat and VbaProject.OTM, etc. I was hoping to
emulate the following type of script (done up in a freeware language
called AutoIt, for those not familiar with the syntax) that gives an
example of one of the paths of Outlook that is easily sent to the
clipboard no matter what computer I am or what the user profile
directory happens to be on the host computer:



ClipPut(@UserProfileDir & "\Application Data\Microsoft\Stationery")



[@UserProfileDir is a poweful tool to use in this language since you
get results with it no matter what.]


I was wondering what the above could be translated into vb so that I
can create other scripts based on that translation, using it as an
example ... ? Can this even be done in vb?

I have these types of AutoIt scripts outside of Outlook and other
office programs and use them all the time but would actually prefer to
have the 3 or so that I use strictly for Outlook saved within the
Outlook OTM scripts file itself and attached to buttons on the
interface. It just would make everything a couple of steps easier
since I would then have immediate access to the information as it'd be
a button click away right there.

Thanks!
 
S

StargateFanNotAtHome

Actually, I just realized that the above could be made even more
efficient if instead of going to the clipboard, the folder itself was
opened. D'uh, that would save even more time since all I'd do with
the clipboard information anyway is to plug it into the address bar of
windows explorer. I keep thinking that vb capabilities in Outlook
don't include windows general scripting needs but that could be way
off.

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)



Sorry, hope I didn't confuse the issue but it only occurred to me
several minutes after posting the initial message in this thread.
Both types of syntax would be great, clipboard and opening a folder;
it's just that the end result is to open an Outlook folder from within
Outlook off of a button with a vb script attached that doesn't have an
absolute path. That's all I have at present but have found all these
years of using this system that it's a pain to have to keep modifying
the paths every new place I go to! Half the time I forget and it's a
pain in the ... <g>

Anyway, thanks. Crossing my fingers that this can be done then I need
ever again have to update those paths!!! Wow, that would be really
neat.

Cheers! :eek:D
 
S

StargateFan

[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?
 
K

Ken Slovak - [MVP - Outlook]

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\Explorer\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\Explorer\Shell
Folders\AppData"

Set WshShell = CreateObject("WScript.Shell")

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




StargateFan said:
[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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top