Extract Filename (including dots) without extension

Sinem

Board Regular
Joined
Nov 8, 2015
Messages
63
Hello,

I canot extract the filename without ".xlsm" because of the dots in the name.

The filename is: "Test 01.01.2019"

Here are my tries:

Code:
  FileName = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5) 

 FileName= Len(ThisWorkbook.Name, InStrRev(ThisWorkbook.Name, ".") - 1)

The Workbook is saved as pdf data with the name "Test 01.01" and if I delete the date then I can save it normally as xlsx
 
Last edited:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I don't want to create a pdf. I want to save my file as xlsx but it is saved as a weird format named "Test 01.01" with type "Excel" but has a pdf symbol. My expected filename is "Test 01.01.2019" as Excel file without macros. So my assumption is that SaveAs has problems with the date format. Since changing the filename to "Test 01-01-2019" works.
 
Upvote 0
Since you grabbed the filename by stripping off the extension, did you remember to add the extension ".xlsx" back when saving?

Sounds like you may not have as what you are describing would have saved as "Test 01.01".2019 meaning a file named "Test 01.01" with an extension of "2019". Which would most likely result in Windows giving it a weird file association like you are describing.
 
Last edited:
Upvote 0
Hi the error occurs during SaveAs action. The name is extracted correctly but the date format "DD.MM.YYYY" prevents SaveAs somehow. If I change the date format to "YY-MM-YYYY" then everything runs as expected.

Does somebody know why SaveAs cannot handle filenames including dots?
 
Upvote 0
Having periods in filenames is poor practice - and is one that has often been exploited by writers of trojan horse software and the like. The code I posted replaces the extraneous periods, thus obviating the problem.
 
Upvote 0
Hi Macropod, I used your code thank you. There is now way to make it with dots I suggest. I shall leave it at that. Thank you
 
Upvote 0

Forum statistics

Threads
1,216,069
Messages
6,128,599
Members
449,460
Latest member
jgharbawi

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