Re: Accesing Directory Issue
Environment.GetFolderPath is a .net call, and you stated you are using VBA, so that is why it isn't working.
Here is a microsoft article on how to get the special folders using VBA:
http://msdn.microsoft.com/en-us/libr...ffice.10).aspx
Re: Accesing Directory Issue
I decided to use the GetUserProfileDirectory function as it seemed a lot more simple
The following code compiles with no errors but when i check C:\Documents and Settings\Alastair the file hasn't been coped across
Quote:
Dim sBuffer As String, Ret As Long, hToken As Long
Declare Function GetUserProfileDirectory Lib "userenv.dll" Alias "GetUserProfileDirectoryA" (ByVal hToken As Long, ByVal lpProfileDir As String, ByVal lpcchSize As Long) As Boolean
Sub Main()
Dim SpecialFolder As String
Dim fs As Object
Dim oldPath As String, newPath As String, specialPath As String
specialPath = GetUserProfileDirectory(hToken, sBuffer, 255)
oldPath = "H:\"
newPath = "specialPath"
fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile(oldPath & "\" & "January2009.txt", newPath & "\" & "January2009.txt")
fs = Nothing
End Sub