Remote running a macro

ChuckDrago

Active Member
Joined
Sep 7, 2007
Messages
470
Office Version
  1. 2010
Platform
  1. Windows
Hi everyone,
I created a macro that parses a text file into Excel in order to manipulate the data into various modalities. The text file (fname.txt) must be placed in a specific folder ("C:\PeakTorque") to be read. Everything went well, as intended...until I sent the macro to our client out of state. He gets an MS message indicating inability to find the file. The way I used to create the parsing routine was to record it. The resulting code is:
Code:
Dim ShfName As String
   ShfName = Left(fName, Len(fName) - 4)
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;C:\PeakTorque\" & fName, Destination:= _
        Range("$B$15"))
        .Name = ShfName
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 65001
        .TextFileStartRow = 52
        .TextFileParseType = xlFixedWidth
        .TextFileTextQualifier = xlTextQualifierNone
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1)
        .TextFileFixedColumnWidths = Array(6, 7, 11, 10, 11, 12, 14)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With

Can anyone provide a hint as to what might be wrong?
As usual, thanks in advance

Chuck
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
The text file (fname.txt) must be placed in a specific folder ("C:\PeakTorque")

If the file is called "fName.txt" then try this:

Rich (BB code):
Sub test()
  Dim ShfName As String, fName As String
  fName = "fname.txt"
  ShfName = Left(fName, Len(fName) - 4)
  With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;C:\trabajo\" & fName, Destination:= _
    Range("$B$15"))
    .Name = ShfName
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 65001
    .TextFileStartRow = 52
    .TextFileParseType = xlFixedWidth
    .TextFileTextQualifier = xlTextQualifierNone
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = False
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1)
    .TextFileFixedColumnWidths = Array(6, 7, 11, 10, 11, 12, 14)
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
  End With
End Sub
 
Upvote 0
Dante, together with my appreciation for your help goes my apology. Our Customer fessed up: his computer had a security setting impeding the reading of the text file! That despite our having asked them if there were any security based impediments! The application worked as intended after they enabled permissions.
Again, thank you.
Chuck
 
Upvote 0

Forum statistics

Threads
1,213,511
Messages
6,114,054
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top