how to hide .CSV file extension ?

A

Ayato

Hello @ll,

I have a macro that saves ".xls" as ".csv" but how can I hide th
".csv" extension (and use for example an extension ".100", and no
".100.csv")

regards,
Ayat
 
B

Bob Flanagan

The following should help. Please note that the file needs to be closed

Dim oldName As String
Dim newName As String
oldName = "c:\temp\book2.csv"
newName = "c:\temp\book2.100"
Name oldFile As newFile

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
A

AA2e72E

In Windows Explorer, click Tools | Folder Options + View tab and check the 'Hide file extensions for known file types' radio button. If you want this to apply to the whole filing system, clicke the 'Like Current Folder' button also.
 
T

TroyW

Does this do what you want?

Workbooks("theworkbooknamehere").SaveAs "thefilename.100", xlCSV

Troy
 
A

Ayato

This is code I use :

'save as Agent Report
ActiveWorkbook.SaveA
Filename:="C:\Reporting\Apple\Agent\24nl_agent." + savedate + "", _
FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=Fals
 
A

Ayato

Bob said:
*The following should help. Please note that the file needs to b
closed

Dim oldName As String
Dim newName As String
oldName = "c:\temp\book2.csv"
newName = "c:\temp\book2.100"
Name oldFile As newFile

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel


Mmmm does not work as I have a variable in the name..
 
T

TroyW

I can't reproduce the behavior that you are reporting. In my testing from
VBA:

----- VBA Programming Interface:
ActiveWorkbook.SaveAs "Test.100", xlCSV
results in a file with the name of: Test.100

ActiveWorkbook.SaveAs "Test.csv", xlCSV
results in a file with the name of: Test.csv

ActiveWorkbook.SaveAs "Test", xlCSV
results in a file with the name of: Test.csv

ActiveWorkbook.SaveAs "Test.100.csv", xlCSV
results in a file with the name of: Test.100.csv

----- Excel User Interface:
If you save the file from the Excel user interface via the "File SaveAs"
dialog box and you type in:
"Test.100" (i.e. including the double quotes!!!!)
and select "CSV (Comma delimited)(*.csv)" as the file format, then Excel
will save the file with the name:
Test.100

If you save the file from the Excel user interface via the "File SaveAs"
dialog box and you type in:
Test.100 (i.e. No double quotes!!!!)
and select "CSV (Comma delimited)(*.csv)" as the file format, then Excel
will save the file with the name:
Test.100.csv

FYI: I have "Hide extensions for known file types" unchecked in my Folder
Options View.

Troy
 
J

Jon Peltier

Can't you make the code remember the variable?

oldname = PathName & "\" & FileName & ".csv"
etc.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
J

Jon Peltier

Bad idea. This might hide an extension of a virus. If its name is
MyFile.xls.exe, it only looks like MyFile.xls, so you try opening the
workbook and instead launch a virus.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top