VBA save as txt file - Uppercase file extension

ddoublev

New Member
Joined
May 22, 2017
Messages
37
Hi,

Currently the below code snippet is used to save a range of data into a tab delimted text file for upload into a database.
I have just found out the file name including extension needs to be uppercase throughout.

Code:
ActiveWorkbook.SaveAs SaveToDirectory & SaveName, xlText

Is there a way to force through VBA the file name save as *.TXT ?

Cheers

Dylan
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Thanks for the response
I have tried that already, no luck.
Below is all the save as code, works perfectly as is except saves as *.txt

Code:
     'To save worksheet as csv
     Sheets(EnviroSys).Activate
     SaveName = "SGS_BHPBIO_" & Site & "_WATER_POTABLEWATER_" & Recorder & "_" & Format(Now, "dd-mm-yy_hh_mm") 'Save file as
     ActiveSheet.Copy 'copies EnviroSys Template
     ActiveWorkbook.SaveAs SaveToDirectory & SaveName, xlText 'saving into C:\temp\
     ActiveWorkbook.Close Savechanges:=False

Any other ideas? Im all out
 
Upvote 0
This sub has been tested to save the file with the upper-case extension:
Code:
Sub Test()
    Site = "Site1"
    Recorder = "Recorder1"
    SaveToDirectory = "C:\Temp\"
    SaveName = "SGS_BHPBIO_" & Site & "_WATER_POTABLEWATER_" & Recorder & "_" & Format(Now, "dd-mm-yy_hh_mm") [COLOR=#ff0000]& ".TXT"[/COLOR]
    ActiveWorkbook.SaveAs SaveToDirectory & SaveName, xlText
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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