Avatar of davidsperling
davidsperling
 asked on

Environ("HOMEPATH") in Vista/Excel 2007

Code below will output:

sHome=\Users\myusername
sMyFolder=\Users\myusername\KALLE
\Users\myusername exists:False
\Users\myusername\KALLE exists:False

I know that both my home folder and "KALLE" exists. It used to work under windows 2000/Office 2000.

Is there a solution or workaround?


Sub Testi()
    
    Dim fso As New FileSystemObject
    Dim sHome, sMyFolder As String
    sHome = Environ("HOMEPATH")
    sMyFolder = sHome & "\KALLE"
    Debug.Print "sHome=" & sHome
    Debug.Print "sMyFolder=" & sMyFolder
    Debug.Print sHome & " exists:" & fso.FolderExists(sHome)
    Debug.Print sMyFolder & " exists:" & fso.FolderExists(sHome)
        
End Sub

Open in new window

Microsoft ExcelMicrosoft OfficeVisual Basic Classic

Avatar of undefined
Last Comment
Chris Bottomley

8/22/2022 - Mon
Chris Bottomley

Hello davidsperling,

Try:
    sHome = Environ("userprofile")
instead of
    sHome = Environ("HOMEPATH")

Regards,

chris_bottomley
davidsperling

ASKER
That will return c:\users\myusername, but that's not correct at the company I'm working at!

The path should be \\domain.company.net\users\myusername\Documents

Is there a way to extract that path?


ASKER CERTIFIED SOLUTION
Chris Bottomley

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
davidsperling

ASKER
Nop, it doesn't :(
Your help has saved me hundreds of hours of internet surfing.
fblack61
Chris Bottomley

I presume they did before, still might be able to do something if we can get to \\domain.company.net\ somewhere i.e. the default outlook client?

Chris
davidsperling

ASKER
>>... still might be able to do something if we can get to \\domain.company.net\ somewhere i.e. the default outlook client?

Don't quite understand :)
Chris Bottomley

if for exampel the default mail address will be fred@domain.company.net and teh mail client is outlook then it coul dbe possible to get teh prefix of \\domain.company.net from outlook and continue by adding the path.  Basically if the necessary information can be reliably assembled from any other data, (i.e. 2 or more environment variable) then that will give us a prospective way to achive your needs.

Chris
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
davidsperling

ASKER
The answer is it's not possible!
Chris Bottomley

Shame, sorry we couldn't help

Chris