【发布时间】:2018-09-20 15:17:52
【问题描述】:
我正在尝试在 Access 中创建包含超链接的 Excel 电子表格的链接表。完成向导后,我的表格在任何地方都没有超链接。字段类型自动设置为短文本。
有人知道修复或解决方法吗?
【问题讨论】:
标签: excel ms-access hyperlink ms-office linked-tables
我正在尝试在 Access 中创建包含超链接的 Excel 电子表格的链接表。完成向导后,我的表格在任何地方都没有超链接。字段类型自动设置为短文本。
有人知道修复或解决方法吗?
【问题讨论】:
标签: excel ms-access hyperlink ms-office linked-tables
我认为你的术语有点混乱,但我猜你指的是这个概念,对吧。
Option Compare Database
Option Explicit
Private Sub Command0_Click()
'Macro Loops through the specified directory (strPath)
'and links ALL Excel files as linked tables in the Access
'Database.
Const strPath As String = "C:\your_path_here\" 'Directory Path
Dim strFile As String 'Filename
Dim strFileList() As String 'File Array
Dim intFile As Integer 'File Number
'Loop through the folder & build file list
strFile = Dir(strPath & "*.csv")
While strFile <> ""
'add files to the list
intFile = intFile + 1
ReDim Preserve strFileList(1 To intFile)
strFileList(intFile) = strFile
strFile = Dir()
Wend
'see if any files were found
If intFile = 0 Then
MsgBox "No files found"
Exit Sub
End If
'cycle through the list of files & link to Access
For intFile = 1 To UBound(strFileList)
DoCmd.TransferText acLinkDelim, , _
strFileList(intFile), strPath & strFileList(intFile), True, ""
'Check out the TransferSpreadsheet options in the Access
'Visual Basic Help file for a full description & list of
'optional settings
Next
MsgBox UBound(strFileList) & " Files were Linked"
End Sub
与 Excel 文件相比,使用更易于使用的 CSV 文件进行练习可能会更好。要遍历文件夹中的 Excel 文件并链接到每个文件,只需更改一行代码。
DoCmd.TransferSpreadsheet acLink, , "Your table name","Path to your workbook file", True, "Sheet1!Ran
【讨论】: