View Full Version : Solved: Specifying path using Environ(UserName) = Runtime Error 5?

Simon Lloyd
02-06-2007, 04:09 AM
Could someone explain why using Environ(UserName) in this line causes Runtime Error 5? r1 = "C:\Documents and Settings\" & Environ(UserName) & "\My Documents\Sales Details For " & c.Valueif i substitute it for Simon then it works fine, if i substitute it for Application.UserName then when my function checks for the filepath and then tries to create it because it doesnt exist using MkDir i get Runtime Error 76 filepath not found, thats because Application.UserName returns Simon Lloyd but my log in name to my personal computer is Simon so the real line would look like this
r1="C:\Documents and Settings\Simon\My Documents\Sales Details For " & c.Value Any ideas?


02-06-2007, 04:13 AM
Because Environ is a function that takes an environ STRING


Simon Lloyd
02-06-2007, 04:21 AM
How could i be so damn stupid???

Simple stuff sillly headache!

Thanks 'O' Great One!

02-06-2007, 04:27 AM
I think you are trying to hard with the formulae. They make your brain hurt, and then one day it clicks. It's a bit like Lego as a kid, you can't build anything, then suddenly you are buyilding skyscrapers (okay, so I may be getting a bit fanciful here).