Get filename in var without path and extension

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
toopnad
Junior Coder
Posts: 34
Joined: Mon Apr 12, 2021 10:10 am
Location: Russian Totalitarian Republic, Perm city

Get filename in var without path and extension

Post by toopnad » Mon Aug 02, 2021 6:42 am

Code: Select all

Let>GFL_TYPE=0
Let>GFL_SORTTYPE=1
IfFileExists>Z:\Обмен\ЗАЯВКИ\ЗАЯВКИ в поставку\ОТЕЧ\2021\*.*
GetFileList>Z:\Обмен\ЗАЯВКИ\ЗАЯВКИ в поставку\ОТЕЧ\2021\*.*,files,;
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
  Let>k=k+1
  Executefile>file_names_%k%
  //Message>file_names_%k%
  //wait>15
  WaitWindowOpen>* - Excel
Until>k,file_names_count
How to get the file name into a variable without path and extension to substitute in waitWindowOpen instead of *?

toopnad
Junior Coder
Posts: 34
Joined: Mon Apr 12, 2021 10:10 am
Location: Russian Totalitarian Republic, Perm city

Re: Get filename in var without path and extension

Post by toopnad » Mon Aug 02, 2021 7:16 am

Code: Select all

 ExtractFileName>file_names_%k%,oldfilename,0
  StringReplace>oldfilename,.xlsb,,strNewString
  WaitWindowOpen>%strNewString% - Excel
I think I did it

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Get filename in var without path and extension

Post by Grovkillen » Mon Aug 02, 2021 8:42 am

Code: Select all

ExtractFileName>file_names_%k%,oldfilename,1
Let>ME=%Script%

Running: 15.0.24
version history

toopnad
Junior Coder
Posts: 34
Joined: Mon Apr 12, 2021 10:10 am
Location: Russian Totalitarian Republic, Perm city

Re: Get filename in var without path and extension

Post by toopnad » Mon Aug 02, 2021 9:00 am

This will shorten the code thanks! May I ask offtopic? If I want to open an Excel file with a password, is it only through VBA? Are there any other options?

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Get filename in var without path and extension

Post by Grovkillen » Mon Aug 02, 2021 4:47 pm

Yes I believe the best way is to use VBA.
Let>ME=%Script%

Running: 15.0.24
version history

toopnad
Junior Coder
Posts: 34
Joined: Mon Apr 12, 2021 10:10 am
Location: Russian Totalitarian Republic, Perm city

Re: Get filename in var without path and extension

Post by toopnad » Mon Aug 02, 2021 5:00 pm

Thank you, I did so, the topic is closed.

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Get filename in var without path and extension

Post by JRL » Mon Aug 02, 2021 6:00 pm

Adding the password at the end of XLOpen> works for me.

Code: Select all

XLOpen>Filename,1,hndl,password

toopnad
Junior Coder
Posts: 34
Joined: Mon Apr 12, 2021 10:10 am
Location: Russian Totalitarian Republic, Perm city

Re: Get filename in var without path and extension

Post by toopnad » Tue Aug 03, 2021 3:10 am

Great news! I'll try)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts