Skip to content

Instantly share code, notes, and snippets.

@ateneva
Last active July 22, 2018 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ateneva/24740fa624a067bb29516d08e6308906 to your computer and use it in GitHub Desktop.
Save ateneva/24740fa624a067bb29516d08e6308906 to your computer and use it in GitHub Desktop.
How do I incorporate my workbook path in my VBA?
Sub ShowUser()
ActiveCell.Value = Environ("UserName") 'returns the domain name
ActiveCell.Offset(1, 0).Value = Application.UserName 'the user registered name
ActiveCell.Offset(2, 0).Value = Application.UserLibraryPath 'location where COM-Addins are installed
ActiveCell.Offset(3, 0).Value = "C:\Users\" & UCase(Environ("UserName")) & "\Desktop" 'returns a custom directory
ActiveCell.Offset(4, 0).Value = ActiveWorkbook.FullName 'the path + the name of the file <-- assimes file has been saved
ActiveCell.Offset(5, 0).Value = ActiveWorkbook.name 'returns the name of the file alone
ActiveCell.Offset(6, 0).Value = ActiveWorkbook.path 'returns the path where it is saved
ActiveCell.Offset(7, 0).Value = Application.PathSeparator 'returns the dash
'hp
'Angelina
'C:\Users\hp\AppData\Roaming\Microsoft\AddIns\
'C:\Users\HP\Desktop
'C:\Users\hp\Google Drive\Analytics\Blogging\Excel Spreadsheets\Get it Right in Excel Workshop.xlsb
'Get it Right in Excel Workshop.xlsb
'C:\Users\hp\Google Drive\Analytics\Blogging\Excel Spreadsheets
'\
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment