We help IT Professionals succeed at work.

Export References

Svgmassive
Svgmassive asked
on
i am looking for a procedure to export references from one database to another in ms access vba
Comment
Watch Question

Software & Systems Engineer
Commented:
It seems that all you need is to export the References to a simple text file
Function ExportReferences()

   Dim strMessage As String

   Dim refItem As Reference
   Dim TextFile As Integer
   Dim delimiter As String
   Dim FilePath As String
   delimiter = ","
   TextFile = FreeFile
   FilePath = Application.CurrentProject.Path & "\ref.txt"
   On Error Resume Next
   Open FilePath For Output As TextFile
   For Each refItem In References
      If refItem.IsBroken Then
         
      Else
         Print #TextFile, refItem.Guid & delimiter & refItem.Major & delimiter & refItem.Minor
      End If
      Debug.Print strMessage
   Next refItem
Close TextFile
End Function

Open in new window

and them import them like this
(you read the text file i create above)
References.AddFromGuid "{420B2830-E718-11CF-893D-00A0C9054228}", 1, 0

Open in new window

John TsioumprisSoftware & Systems Engineer
Commented:
To read and add
Function ImportReferences()
Dim FilePath As String
Dim dataline As String
Dim RefInfo() As String
FilePath = Application.CurrentProject.Path & "\ref.txt"
Dim TextFile As Integer
TextFile = FreeFile
Open FilePath For Input As #TextFile
While Not EOF(TextFile)
Line Input #TextFile, dataline
RefInfo = Split(dataline, ",")
References.AddFromGuid RefInfo(0), RefInfo(1), RefInfo(2)
Wend
Close TextFile
End Function

Open in new window