Hi,
I've created some hotkeys for Excel. That works fine. How can I get the filepath of the current Excel file?
Regards,
Anika
How to get filepath of current file (Excel)
Re: How to get filepath of current file (Excel)
Code: Select all
Xl := ComObjActive("Excel.Application")
MsgBox % Xl.ActiveWorkbook.Path
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Re: How to get filepath of current file (Excel)
ADR_ wrote:Hi,
I've created some hotkeys for Excel. That works fine. How can I get the filepath of the current Excel file?
Regards,
Anika
Hello! I am not a coder but I think you can do it like this:
Code: Select all
xl := ComObjActive("Excel.Application")
MsgBox, %xl.ActiveWorkbook.Path%
Re: How to get filepath of current file (Excel)
This should do it.
Code: Select all
;[Excel_Get function]
;MS-Office-COM-Basics/Excel_Get.ahk at master · ahkon/MS-Office-COM-Basics · GitHub
;https://github.com/ahkon/MS-Office-COM-Basics/blob/master/Examples/Excel/Excel_Get.ahk
q:: ;excel - get path
oXl := Excel_Get()
vPath := oXl.ActiveWorkbook.FullName ;dir+name
vDir := oXl.ActiveWorkbook.Path ;dir
vName := oXl.ActiveWorkbook.Name ;name
MsgBox, % vPath "`r`n" vDir "`r`n" vName
oXl := ""
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: How to get filepath of current file (Excel)
Thank you for your prompt reactions. However, I haven't got the faintest idea how to test the options (I've tried all of them). Can you tell me step by step where to put the code? Sofar all my attempts have failed.