Sub GoogleDrivePathOnLocalPC()
Dim chrome As Object
Set chrome = CreateObject("Shell.Application")
chrome.ShellExecute "chrome.exe", "https://drive.google.com/drive/my-drive", "", "", 1
Dim link As String
link = InputBox("Please enter a Google Drive link", "Extract Folder Path")
Dim drivePath As String
drivePath = GetGoogleDrivePath(link)
If drivePath = "False" Then
Exit Sub
End If
MsgBox "Drive Path: " & drivePath
Dim desiredFile As Variant
desiredFile = Application.GetSaveAsFilename(InitialFileName:="OutputFile.txt", FileFilter:="Text Files (*.txt), *.txt")
Open desiredFile For Output As #1
Print #1, drivePath
Close #1
End Sub
Function GetGoogleDrivePath(link As String) As String
Dim startPos As Integer
startPos = InStr(link, "/drive/folders/")
If startPos = 0 Then
GetGoogleDrivePath = "Invalid Google Drive link"
Exit Function
End If
startPos = startPos + Len("/drive/folders/")
Dim endPos As Integer
endPos = InStr(startPos, link, "/")
If endPos = 0 Then
endPos = Len(link) + 1
End If
GetGoogleDrivePath = Mid(link, startPos, endPos - startPos)
End Function