【发布时间】:2017-12-21 00:05:15
【问题描述】:
我有这个数据库,它运行良好,但今天它开始讨厌我。我开始收到编译错误:找不到项目或库。我环顾四周,发现在另一台计算机上使用前端时,在 VBA 和引用下,它缺少 Microsoft Word 15.0 对象库的引用。
我的电脑我检查了 Microsoft Word 16.0 对象库。我怎样才能让它在其他具有 15.0 和 16.0 的计算机上工作?
这里是代码
Private Sub cmd_LocateFile_Click()
On Error GoTo Error_Handler
Dim sFile As String
Dim sFolder As String
Dim ID As Long
Dim sTarget As String
sFile = FSBrowse("", msoFileDialogFilePicker, "All Files (*.*),*.*")
If sFile <> "" Then
sFolder = ("\\aiowima23fp1\Ecological Sciences and Engineering\Cultural Resources\New - Cultural Resources Request Database") & "\" & sAttachmentFolderName & "\"
If FolderExist(sFolder) = False Then MkDir (sFolder)
ID = RequestID_FK ' Set current record id.
sTarget = sFolder & CStr(ID) & "-" & GetFileName(sFile)
If CopyFile(sFile, sFolder & GetFileName(sTarget)) = True Then
Me!FullFileName.Value = sTarget
Else
End If
End If
Error_Handler_Exit:
On Error Resume Next
Exit Sub
Error_Handler:
MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: " & sModName & "\cmd_LocateFile_Click" & vbCrLf & _
"Error Description: " & Err.Description & _
Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
, vbOKOnly + vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Sub
【问题讨论】:
-
使用后期绑定。如果你想要比这更具体的东西,你需要分享你的代码。
-
我编辑了问题以包含代码
-
请包含依赖于 Microsoft Word 对象库参考的代码,而不仅仅是随机代码。