Mr_Ragweed2
Board Regular
- Joined
- Nov 11, 2022
- Messages
- 145
- Office Version
- 365
- Platform
- Windows
Sorry for a dumb question here but how do i take the .xlsx out of a filename/string? The filename/string is dynamic in length.
I have some .xlsx files i am saving as .PDF files and for some reason (prolly because i coded it that way) it is saving them as a "file name.xlsx.pdf" . The "file name.xlsx" is a String. So i just want to edit that string and lop off the .xlsx. So basically lop off the last 5 characters of a string. I'm no good at the LEN/UBound/LBound/LEFT/MID/Right thing if it has something to do with that. haha
This is as far as i have gotten on that bit.
To add background i used filename as a String in a pathway to save to another location. I now want to switch the string in that save as pathway to newName. Then i kill the original filename.
I can put the whole code here if needed. It's not super long and is a loop.
Thanks in advance.
I have some .xlsx files i am saving as .PDF files and for some reason (prolly because i coded it that way) it is saving them as a "file name.xlsx.pdf" . The "file name.xlsx" is a String. So i just want to edit that string and lop off the .xlsx. So basically lop off the last 5 characters of a string. I'm no good at the LEN/UBound/LBound/LEFT/MID/Right thing if it has something to do with that. haha
This is as far as i have gotten on that bit.
VBA Code:
fileName = File.Name
newName =
VBA Code:
If fileName Like "*SWO*.xlsx" Then
ActiveWorkbook.SaveAs fileName:= _
"https://abcd.sharepoint.com/teams/mycompany/Shared%20Documents/General/Crystal,%20Mary,%20Anna/Propane%20Service%20Work%20Orders/" _
& newName & ".PDF" 'newName used to be filename but that's when the issues arose
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF
Kill "C:\Users\" & MyName & "\OneDrive - MyCompany\Desktop\Propane Forms\" & fileName
Thanks in advance.