File extensions hidden vs. visible

cgclower

New Member
Joined
Feb 28, 2010
Messages
40
I am wondering if anyone can shed some light on how having file extensions hidden vs. visible in a folder effects macros run on files in that folder.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
For example, with the target file already open, I get a new file name from the user, then rename and close the file:
<o:p></o:p>
<o:p></o:p>newcsvfilename = InputBox("Input name for this new CSV file:")
ActiveWorkbook.SaveAs Filename:=newcsvfilename, FileFormat:=xlCSV
Workbooks(newcsvfilename).Close False
<o:p></o:p>
This works fine when the folder with the original file in it has file extensions off, but crashes on the last line when file extensions are on. Anyone know why, or how to fix this?
<o:p></o:p>
Thanks!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
If file extensions are on you have to supply the extension. If file extensions are off the code should work whether or not you include the extension.
 
Upvote 0
I had this issue and fixed it like this:

Filename:=newcsvfilename & ".csv"
 
Upvote 0

Forum statistics

Threads
1,215,165
Messages
6,123,390
Members
449,098
Latest member
ArturS75

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