Open different date of text file

Linda Lo

New Member
Joined
May 15, 2023
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
Dear all,

I want to open a text file with following but it doesn't work. Please help to point out.

VBA Code:
Dim Ag as Variant

Ag = Format (Cells(2,4), "YYYY-MM-DD")

ChDir: "T:\TEMP\Stock Closing Pr\backup\2024\Ag"
Workbooks.OpenText Filename:_
"T:\TEMP\Stock Closing Pr\backup\2024\" & Ag & "\CTFCLOSPRIC",Origin:=950, StartRow:=1, DataType:=x1FixdWidth, FieldInfo:= Array(0,1), Array(1,1), Array(5,1), TrailingMinusNumbers:= True

Thanks,
Linda
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Are you getting a specific error, or is it just not working?
If you are getting an error, what is the exact error message?

What is the EXACT FULL file path and name of the file?
Does the file have any extension on it (like . TXT, .CSV, .TAB, .DAT, etc)?
 
Upvote 0
I see your VBA code, but no image in the first post.
Do you see an image in the first post?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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