|
-
August 18th, 2005, 02:36 AM
#1
how to save file to Desktop?
hi,
i like to export a file to .xls that located in Desktop
but if the UserName or WindowLogin or ComputerName(not sure which one is the correct ) change the the path will also changed
ex : "C:\Documents and Settings\eRiCk\Desktop"
"C:\Documents and Settings\Vaio\Desktop"
how to solve this?
thanks
-
August 18th, 2005, 03:58 AM
#2
Re: how to save file to Desktop?
You can invoke the GetUserProfileDirectory(...) located in Userenv.lib to abtain the directory like "C:\Documents and Settings\Joe".
- petter
-
August 18th, 2005, 04:21 AM
#3
Re: how to save file to Desktop?
You can use the SHGetFolderPath API to get the desktop folder.
Code:
Private Const CSIDL_DESKTOPDIRECTORY As Long = &H10
Private Declare Function SHGetFolderPath Lib "shfolder" _
Alias "SHGetFolderPathA" (ByVal hwndOwner As Long, _
ByVal nFolder As Long, ByVal hToken As Long, _
ByVal dwFlags As Long, ByVal pszPath As String) As Long
Private Sub Command1_Click()
Dim strPath As String, lRet As Long
strPath = String(255, 0)
lRet = SHGetFolderPath(0, lngCSIDL, 0, SHGFP_TYPE_CURRENT, strPath)
strPath = Left$(strPath, InStr(1, strPath, Chr(0)) - 1)
MsgBox strPath
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|