Results 1 to 11 of 11

Please help - VBA isn't reading my Environment variable

Threaded View

Chinoxl Please help - VBA isn't... 09-15-2020, 04:07 PM
vba_php Re: Please help - VBA isn't... 09-15-2020, 09:02 PM
Chinoxl Re: Please help - VBA isn't... 09-15-2020, 11:59 PM
vba_php Re: Please help - VBA isn't... 09-16-2020, 12:07 AM
Chinoxl Re: Please help - VBA isn't... 09-16-2020, 11:58 AM
vba_php Re: Please help - VBA isn't... 09-16-2020, 12:07 PM
Chinoxl Re: Please help - VBA isn't... 09-16-2020, 12:33 PM
Chinoxl Re: Please help - VBA isn't... 09-16-2020, 12:59 PM
romperstomper Re: Please help - VBA isn't... 09-16-2020, 04:45 AM
Chinoxl Re: Please help - VBA isn't... 09-16-2020, 12:24 PM
vba_php Re: Please help - VBA isn't... 09-16-2020, 03:36 PM
  1. #1
    Registered User
    Join Date
    05-14-2020
    Location
    England
    MS-Off Ver
    2010
    Posts
    13

    Please help - VBA isn't reading my Environment variable

    Hi, sorry if this is a simple fix. I have created a user environment variable and named it OLIMARO.
    This environment variable is supposed to point to the following folder: %userprofile%\documents\olimaro-2.3\
    in the file path referenced above, I want to run a batch file named "run_olimaro.bat" via vba.

    I have created this macro but it doesn't seem to be working
    Sub RunOlimaro()
    Dim folderPath As String
    folderPath = Environ("OLIMARO")
    Shell folderPath & "\run_olimaro"
    End Sub


    However placing the full path without specifying the environment variable seems to run.

    Shell c:\Users\Chinoxl\documents\olimaro-2.3\

    but I dont want to run the full path as I need it to run on a different computer where the folder path might be different.
    What am I doing wrong? Please help.


    EDIT: The solution was: Excel needs to be restarted each time the path in an existing environment variable is changed before the new path can be considered in the code. Using MsgBox in reading the value from the Environment variable path was helpful in recognizing what path was referenced in VBA.
    Attached Files Attached Files
    Last edited by Chinoxl; 09-17-2020 at 04:50 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. open textfile from path defined by environment variable
    By proepert in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-14-2010, 11:25 PM
  2. [SOLVED] Finding temp folder. Environment variable?
    By Don Wiss in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-15-2006, 01:10 PM
  3. Environment Variable Names
    By Chaplain Doug in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-20-2006, 10:35 AM
  4. Can you set a Window's Environment variable in VB
    By Ken Soenen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2006, 02:25 PM
  5. Environment Variable
    By Andibevan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-03-2005, 11:05 AM
  6. Using an Array in Environment Variable
    By Jack Gillis in forum Excel General
    Replies: 6
    Last Post: 06-14-2005, 03:05 PM
  7. Changing an Environment Variable.
    By Jack Gillis in forum Excel General
    Replies: 5
    Last Post: 03-08-2005, 04:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1