Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

VB.net Excel Add-in manipulating text files via Access

Hi

I am using the following VB.net code to link an Access table to a text file
so that I can run a query on the data. I want to be able to automatically
do this with different text files coming from different database sources.
Is this technique reliable?

  Dim appAccess As New Microsoft.Office.Interop.Access.Application
        appAccess.OpenCurrentDatabase("C:\Users\murbro\Documents\Database1.accdb")
        appAccess.Visible = True

        'Link to a csv file so that it acts as a table in Access
        appAccess.DoCmd.TransferText(TransferType:=Microsoft.Office.Interop.Access.AcTextTransferType.acLinkDelim, TableName:="tblImport", _
    FileName:="C:\Users\murbro\Documents\MyData.txt", HasFieldNames:=True)
0
Murray Brown
Asked:
Murray Brown
  • 2
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
yes, just change this part

 FileName:="C:\Users\murbro\Documents\MyData.txt"

to connect to the other text file.

if you will use the same table "TableName:="tblImport""

make sure to delete the table before linking
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks. Does that mean that I don't have to use import specifications.

Thanks
0
 
Rey Obrero (Capricorn1)Commented:
No, Import Spec is for Importing not for Linking files.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Great. Thanks very much
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now