How to change path in Saved Import Spec (1 Viewer)

sumdumgai

Registered User.
Local time
Yesterday, 21:16
Joined
Jul 19, 2007
Messages
453
Ran into a problem and need some help. I know it can be done but am having trouble finding VBA code that changes the path to an input file for a Saved Import Spec. I'm not familiar with XML but I believe there's a way to modify it with VBA.


Many thanks for any help.
 

sumdumgai

Registered User.
Local time
Yesterday, 21:16
Joined
Jul 19, 2007
Messages
453
Would something like this be sufficient and effective:


Code:
    With CurrentProject.ImportExportSpecifications("spec name")
        startpos = InStr(.XML, "Path = ") + Len("Path = ") + 1
        endpos = InStr(.XML, "xmlns") - 2
        
        varSavedPathName = Mid(.XML, startpos, endpos - startpos)
        varnewpathname = "C:\Folder\Subfolder\file.txt"
        
        .XML = Replace(.XML, varSavedPathName, varnewpathname)
    End With


Can I always depend on the spec path being bounded by 'Path = ' and 'xmlns'?
 

Users who are viewing this thread

Top Bottom