Can Outlook use a variable that was defined in Access 2003?

Danick

Registered User.
Local time
Today, 13:37
Joined
Sep 23, 2008
Messages
377
In Access 2003, I’m creating a directory in Windows.

Code:
Dim strPath As String
strPath = Application.CurrentProject.Path & "\Reference\"
    If Len(Dir(strPath, vbDirectory)) = 0 Then
        MkDir strPath
    End If
Shell "EXPLORER.EXE " & strPath, vbNormalFocus


In Outlook, I have a macro that will store messages into a folder using a function called BrowseForFolder

Code:
Dim previousPath As Variant
Dim strFolderpath As String
strFolderpath = BrowseForFolder(previousPath)


This works fine as a two step operation. First create the folder in Access then browse to that folder using the Outlook Macro to store the message. But it would be even better if I can use Access to create the folder and have the “previousPath” available to Outlook.

Is that possible to have a variable used in Access available to other applications like Outlook?
 
The way I do it is either write the data to a text file (.txt or .ini) or to an Access table.

Then the other application can read it data.

Curious, Why do you need Access VBA to create the folder?

Did you now that Outlook VBA code can read and write to an Access database?
 
The way I do it is either write the data to a text file (.txt or .ini) or to an Access table.

Then the other application can read it data.

Curious, Why do you need Access VBA to create the folder?

Did you now that Outlook VBA code can read and write to an Access database?

Do you have a sample mdb or VBA of how to do that? I am already writing the folder location to an Access table when I create it in Access.

The reason I use Access to create the folder is because I just use Outlook for email. My Access database is more of a CRM tool that does it all. So I'll save the msg in a folder using Outlook and have links in my Access database to refer to it as well as open it.
 
OK I found a way to store the path to a temp txt file. I thought this would be easier than trying to get Outlook to get the path from Access.

Code:
    Dim fn As String
    fn = Application.CurrentProject.Path & "\TempFilePath.txt"
    Open fn For Output As #1
    Write #1, strPath
    Close #1

Now I just have to figure out how to read it into my Outlook macro
 
So for anyone who may need this in the future, I figured out how to get this to work.

Code:
        'From Access, Writing the file path to a text file
    Dim fn As String
    fn = Application.CurrentProject.Path & "\TempFilePath.txt"
    Open fn For Output As #1
    Print #1, strPath;
    Close #1

Code:
' *******  From Outlook, Get File Path from External File
Dim enviro As String
Dim TextFile As Integer
Dim FilePath As String
Dim FileContent As String
Dim sPath As String

enviro = CStr(Environ("USERPROFILE"))

  FilePath = enviro & "\Documents\TempFilePath.txt"
  TextFile = FreeFile
  Open FilePath For Input As TextFile
  FileContent = Input(LOF(TextFile), TextFile)
  Close TextFile

sPath = FileContent & "\"

Hope this helps someone in the future. It works for me...
Good luck
 
Thanks for paying it forward by sharing your solution.

Great Job!
 

Users who are viewing this thread

Back
Top Bottom