Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Nov 2013
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Import a Specific File

    Hello,

    This script does Application.GetOpenFilename instead of that i need a fixed/Specific text file from "D:\database\costing\global.txt" always.
    Please help to modify.

    Thanks.

    Code:
    Sub global()
        Dim fn As String, txt, m, n As Long, temp, a(), x, myArea
        fn = Application.GetOpenFilename("TextFiles,*.txt")
        If fn = "False" Then Exit Sub
        n = 1: ReDim a(1 To 1): a(n) = Array("Settle", "Units", "Costing"):
        txt = CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll
        temp = txt
        With CreateObject("VBScript.RegExp")
    
    .....script continue

  2. #2
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,637
    Thanks
    115
    Thanked 650 Times in 592 Posts
    Carmine,

    Try....

    Code:
    Public Sub global1()
        Dim fn As String, txt, m, n As Long, temp, a(), x, myArea
        fn = "D:\database\costing\global.txt"
        n = 1: ReDim a(1 To 1): a(n) = Array("Settle", "Units", "Costing"):
        txt = CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll
        temp = txt
        With CreateObject("VBScript.RegExp")
        
    
    '.....script continue
    End Sub
    
    BTW, You cannot use global for the sub name.  It is a reserved key word in VBA

  3. #3
    Lounger
    Join Date
    Nov 2013
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks Maudibe its working.
    Many Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •