MS Access HOMEPATH保存了导出

时间:2011-05-17 14:52:34

标签: ms-access export

我目前正在使用Microsoft Access 2007并且我已经在程序上创建了几个已保存的导出,然后我将它们设置为按钮以供使用。这个数据库必须在几台不同的计算机上使用,因为我的用户名在其他机器上不足以作为保存导出的目录的一部分,我一直试图在windows中使用%homepath%变量来替换管理数据任务窗口中的路径,但没有运气,有任何人遇到此问题,或有另一种方法来处理这个,文件必须导出到任何Windows系统上的my documents文件夹beyone xp

2 个答案:

答案 0 :(得分:0)

可以将它们导出到共享驱动器吗?

答案 1 :(得分:0)

将以下代码复制并粘贴到标准代码模块中。请致电如下:

Debug.Print SpecFolder(CSIDL_PERSONAL)

'----- Special Folder declarations -------------------------------------------'
'"Identify the Location of Special Folders with API Calls" article in MSDN    '
'See http://msdn.microsoft.com/en-us/library/aa140088(office.10).aspx for more info'
''
'Declaration section for APIs needed to get the path to My Documents:'
Private Declare Function SHGetSpecialFolderLocation _
                          Lib "Shell32" _
                              (ByVal hWnd As Long, ByVal nFolder As Long, ppidl As Long) As Long

Private Declare Function SHGetPathFromIDList _
                          Lib "Shell32" Alias "SHGetPathFromIDListA" _
                              (ByVal Pidl As Long, ByVal pszPath As String) As Long

Private Declare Sub CoTaskMemFree Lib "ole32" (ByVal pvoid As Long)

Private Const MAX_PATH = 260
Private Const NOERROR = 0

Public Enum CSIDL
    CSIDL_PERSONAL = &H5             'Current user My Documents'
    CSIDL_DESKTOPDIRECTORY = &H10    'Current user Desktop'
    CSIDL_MYPICTURES = 39            'Current user My Pictures'
End Enum
'================================================================='

Function SpecFolder(ByVal Folder As CSIDL) As String
Dim PidlFound As Long, FolderFound As Long
Dim Pidl As Long, strPath As String

    'Create buffer to hold path'
    strPath = Space(MAX_PATH)
    'Find Pointer to item ID List (PIDL)'
    PidlFound = SHGetSpecialFolderLocation(0, Folder, Pidl)
    If PidlFound = NOERROR Then
        'Look up path to special folder using the PIDL we found above'
        FolderFound = SHGetPathFromIDList(Pidl, strPath)
        If FolderFound Then
            'Return only the portion of the string buffer we want'
            '  (everything up to the null terminating character)'
            SpecFolder = Left$(strPath, _
                               InStr(1, strPath, vbNullChar) - 1)
        End If
    End If
    'When an API function creates a PIDL, memory is automatically allocated to storing it'
    '   CoTaskMemFree frees that allocated memory'
    CoTaskMemFree Pidl
End Function