[AccessD] Export file to desktop

Rocky Smolin - Beach Access Software bchacc at san.rr.com
Wed May 25 18:27:27 CDT 2005


Stuart:

Thanks.  Is that reliable enough to incorporate into an app that hopefully 
will go out to hundreds of different machines?  It's temporary.  We just 
need it while beta testing the Sleep Advisor.  People are having a hard time 
finding the files that we export.  They're in C:\TheSleepAdvisor but even 
that stumps some people.  So I figured if I could put them on the desktop 
that would be about as simple as it could be made.



Rocky

----- Original Message ----- 
From: "Stuart McLachlan" <stuart at lexacorp.com.pg>
To: "Access Developers discussion and problem solving" 
<accessd at databaseadvisors.com>
Sent: Wednesday, May 25, 2005 4:07 PM
Subject: Re: [AccessD] Export file to desktop


> On 25 May 2005 at 15:39, Rocky Smolin - Beach Access S wrote:
>
>> Dear List:
>>
>> Is there a way to export a file to the desktop without knowing the exact 
>> path and/or user?
>>
>> I'm currently using:
>>
>>     Open strFolder & rstPatient!fldPatientName & "1.TXT" For Output As #1
>>
>> where strFolder contains the full path of the database.  But I'd rather 
>> put the file on the desktop.
>>
>
>
> Use API calls to find the Desktop path.  Here's a module to do that. By
> using different CSIDLs, you can get the path to any system folder.
>
> Option Compare Database
> Option Explicit
>
> Const CSIDL_DESKTOP = &H0
> Const CSIDL_PROGRAMS = &H2
> Const CSIDL_CONTROLS = &H3
> Const CSIDL_PRINTERS = &H4
> Const CSIDL_PERSONAL = &H5
> Const CSIDL_FAVORITES = &H6
> Const CSIDL_STARTUP = &H7
> Const CSIDL_RECENT = &H8
> Const CSIDL_SENDTO = &H9
> Const CSIDL_BITBUCKET = &HA
> Const CSIDL_STARTMENU = &HB
> Const CSIDL_DESKTOPDIRECTORY = &H10
> Const CSIDL_DRIVES = &H11
> Const CSIDL_NETWORK = &H12
> Const CSIDL_NETHOOD = &H13
> Const CSIDL_FONTS = &H14
> Const CSIDL_TEMPLATES = &H15
> Const MAX_PATH = 260
> Private Type SHITEMID
>    cb As Long
>    abID As Byte
> End Type
> Private Type ITEMIDLIST
>    mkid As SHITEMID
> End Type
> Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll"
> (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As
> Long
> Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias
> "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As
> Long
>
> Private Function GetSpecialfolder(CSIDL As Long) As String
>    Dim lngResult As Long
>    Dim strPath As String
>    Dim IDL As ITEMIDLIST
>    lngResult = SHGetSpecialFolderLocation(100, CSIDL, IDL)
>    If lngResult = 0 Then
>        strPath = Space$(512)
>        lngResult = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal strPath)
>        GetSpecialfolder = Left$(strPath, InStr(strPath, Chr$(0)) - 1)
>        Exit Function
>    End If
>    GetSpecialfolder = ""
> End Function
>
> Function GetDesktopPath() As String
>    GetDesktopPath = GetSpecialfolder(CSIDL_DESKTOP)
> End Function
> -- 
> Stuart
>
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 




More information about the AccessD mailing list