File not saving with correct file type

MDennison

New Member
Joined
Mar 13, 2025
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I'm on Office365, and using VBA to open a bunch of files in a directory, manipulate them, then save them in a different format (txt) and according to a naming convention.
My issue is in the saving as a filetype and following the naming convention.

I am using:
Code:
Dim Path As String
    Path = Worksheets("FileSave").Cells(4, 3).Value
Dim filename As String
    filename = Worksheets("FileSave").Cells(5, 3).Value
    ActiveWorkbook.SaveAs filename:=Path & filename, FileFormat:=xlTextWindows

To save workbooks as text files for upload.
Our naming convention is to have a payment amount in the filename. Which is not an issue when I manually save a file, but when using this, I cannot properly save a file with a "." in it.
Example:
A filename like: Vendor - Date - Batch Total $1,108,358.46 saves as a filetype 46 instead of as .txt. Is there anyway to get past this? I'm trying to eliminate the renaming/manual naming of hundreds of files and also trying not to have to push for a new filenaming convention.

Thanks for any help you could throw my way.
 
Try adding the extension explicitly:

VBA Code:
filename = Worksheets("FileSave").Cells(5, 3).Value & ".txt"
 
Upvote 0
Solution

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