2017-12-20 12 views
0

나는이 데이터베이스를 가지고 있으며 완벽하게 작동하지만 오늘은 나를 미워하기 시작했습니다. 컴파일 오류가 발생하기 시작했습니다 : 프로젝트 또는 라이브러리를 찾을 수 없습니다. 주변을 둘러 보았을 때 VBA 및 참조에서 다른 컴퓨터의 프런트 엔드를 사용할 때 Microsoft Word 15.0 개체 라이브러리에 대한 참조가 누락되었다는 것을 알았습니다.MS 액세스 VBA 참조

내 컴퓨터 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 
+3

후기 바인딩을 사용하십시오. 그보다 더 구체적인 것을 원하면 코드를 공유해야합니다. –

+0

코드를 포함하도록 질문을 편집했습니다. –

+0

임의 코드뿐 아니라 Microsoft Word Object Library 참조에 의존하는 코드를 포함하십시오. –

답변

0

입니다 인텔리을 활용할 수있는, 따라서 강력한 형식의 단어 객체를 사용할 수 및 수있는 장점이있다. 그러나 이러한 참조는 경험 한대로 버전 관리에 합리적인 것입니다. 따라서 개발이 완료되면 Word에 대한 참조를 제거하는 것이 좋습니다. 또한 모든 단어 관련 유형을 Object으로 대체해야합니다 (예 : 후기 바인딩 사용). 이렇게하면 버전 관리와 관련하여 응용 프로그램이보다 강력 해집니다.

Word DLL에 대한 참조없이이 코드 조각을 사용하여 이미 열려있는 기존 Word 인스턴스를 가져 오거나 새 Word 인스턴스를 열 수 있습니다.

Public Function GetWordApplication() As Object 
    'Gets an active Word application or opens a new Word instance. 
    'Raises Error No. 8 if word cannot be opened. 

    On Error Resume Next 
    'Find existing instance of Word 
    Set GetWordApplication = GetObject(, "Word.Application") 
    If Err.Number <> 0 Then 'Not found, create new instance. 
     Set GetWordApplication = CreateObject("Word.Application") 
    End If 

    'Following code is optional. You can instead test for Nothing at the call site 
    On Error Goto 0 
    If GetWordApplication Is Nothing Then 
     Err.Raise 8, "YourApp.GetWordApplication", "Word could not be opened." 
    End If 
End Function 
+0

정말 고마워요! 당신은 생명의 은인입니다! –