Open webpage then select options then copy (1 Viewer)

stu_c

Registered User.
Local time
Today, 14:33
Joined
Sep 20, 2007
Messages
489
Hi All
I know this is a big ask, and so many have helped me to date, hopefully someone can help.
on our database we produce passwords using the website:

I have a button called BTNPassGenerator, when the user clicks on this ideally the following process needs to be done
> Open website https://bitwarden.com/password-generator (in edge or chrome)
>Type - Passphrase
> Words: 3
> Capitalize - YES
> Include Number - YES

Once this is done then copies the password and Pastes into back into the Access textbox TXTPassword

Thanks in advance!
Stu
 

cheekybuddha

AWF VIP
Local time
Today, 14:33
Joined
Jul 21, 2014
Messages
2,288
They have a CLI which would make this much easier.

I just downloaded it and ran this from the command line:
Code:
PS C:\Users\dm> .\Downloads\bw-windows-2023.1.0\bw.exe generate --passphrase --words 3 --capitalize --includeNumber
Devotedly-Provider-Cavalry4

So, if you save the executable somewhere you can get the output using Shell()
 

stu_c

Registered User.
Local time
Today, 14:33
Joined
Sep 20, 2007
Messages
489
unfortunately we have to use their website
 

cheekybuddha

AWF VIP
Local time
Today, 14:33
Joined
Jul 21, 2014
Messages
2,288
Here's a function you can use to generate passwords or phrases using the CLI:
Code:
Function GeneratePW( _
           Optional LengthOrWordCount As Integer = 3, _
           Optional blPassphrase As Boolean = True, _
           Optional blIncludeNumbers As Boolean = True, _
           Optional blCapitals As Boolean = True, _
           Optional blLowercase As Boolean = True, _
           Optional blSpecialChars As Boolean = False _
         ) As String

  Const PATH_TO_BITWARDEN As String = "C:\Users\stu_c\bitwarden\bw-windows-2023.1.0\bw.exe"  ' <-- *** Change to wherever you have saved the bitwarden excutable ***
  Const GENERATE          As String = "generate"
  Const PASSPHRASE        As String = "--passphrase"
  Const WORDS             As String = "--words"
  Const CAPITALIZE        As String = "--capitalize"
  Const NUMBERS           As String = "--includeNumber"
  Const UPPERCASE         As String = "u"
  Const LOWERCASE         As String = "l"
  Const NUMBER            As String = "n"
  Const SPECIAL           As String = "s"
  Const PW_LENGTH         As String = "--length"
  Const MIN_PW_LENGTH     As Integer = 5
  Const WSCRIPT_SHELL     As String = "WScript.Shell"
    Dim strCmd            As String

 If blPassphrase Then
    strCmd = PASSPHRASE & " " & WORDS & " " & LengthOrWordCount
    strCmd = strCmd & IIf(blCapitals, " " & CAPITALIZE, vbNullString)
    strCmd = strCmd & IIf(blIncludeNumbers, " " & NUMBERS, vbNullString)
  Else
    strCmd = "-"
    strCmd = strCmd & IIf(blCapitals, UPPERCASE, vbNullString)
    strCmd = strCmd & IIf(blLowercase, LOWERCASE, vbNullString)
    strCmd = strCmd & IIf(blIncludeNumbers, NUMBER, vbNullString)
    strCmd = strCmd & IIf(blSpecialChars, SPECIAL, vbNullString)
    strCmd = strCmd & " " & PW_LENGTH & " " & IIf(LengthOrWordCount > MIN_PW_LENGTH, LengthOrWordCount, MIN_PW_LENGTH)
  End If
  strCmd = PATH_TO_BITWARDEN & " " & GENERATE & " " & strCmd
  Debug.Print strCmd

  With CreateObject(WSCRIPT_SHELL)
    With .Exec(strCmd)
      GeneratePW = .StdOut.ReadAll
    End With
  End With

End Function
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:33
Joined
May 7, 2009
Messages
19,247
Once this is done then copies the password and Pastes into back into the Access textbox TXTPassword
this is the simplest and is good for your heart (exercise those fingers).
 

stu_c

Registered User.
Local time
Today, 14:33
Joined
Sep 20, 2007
Messages
489
Here's a function you can use to generate passwords or phrases using the CLI:
Code:
Function GeneratePW( _
           Optional LengthOrWordCount As Integer = 3, _
           Optional blPassphrase As Boolean = True, _
           Optional blIncludeNumbers As Boolean = True, _
           Optional blCapitals As Boolean = True, _
           Optional blLowercase As Boolean = True, _
           Optional blSpecialChars As Boolean = False _
         ) As String

  Const PATH_TO_BITWARDEN As String = "C:\Users\stu_c\bitwarden\bw-windows-2023.1.0\bw.exe"  ' <-- *** Change to wherever you have saved the bitwarden excutable ***
  Const GENERATE          As String = "generate"
  Const PASSPHRASE        As String = "--passphrase"
  Const WORDS             As String = "--words"
  Const CAPITALIZE        As String = "--capitalize"
  Const NUMBERS           As String = "--includeNumber"
  Const UPPERCASE         As String = "u"
  Const LOWERCASE         As String = "l"
  Const NUMBER            As String = "n"
  Const SPECIAL           As String = "s"
  Const PW_LENGTH         As String = "--length"
  Const MIN_PW_LENGTH     As Integer = 5
  Const WSCRIPT_SHELL     As String = "WScript.Shell"
    Dim strCmd            As String

If blPassphrase Then
    strCmd = PASSPHRASE & " " & WORDS & " " & LengthOrWordCount
    strCmd = strCmd & IIf(blCapitals, " " & CAPITALIZE, vbNullString)
    strCmd = strCmd & IIf(blIncludeNumbers, " " & NUMBERS, vbNullString)
  Else
    strCmd = "-"
    strCmd = strCmd & IIf(blCapitals, UPPERCASE, vbNullString)
    strCmd = strCmd & IIf(blLowercase, LOWERCASE, vbNullString)
    strCmd = strCmd & IIf(blIncludeNumbers, NUMBER, vbNullString)
    strCmd = strCmd & IIf(blSpecialChars, SPECIAL, vbNullString)
    strCmd = strCmd & " " & PW_LENGTH & " " & IIf(LengthOrWordCount > MIN_PW_LENGTH, LengthOrWordCount, MIN_PW_LENGTH)
  End If
  strCmd = PATH_TO_BITWARDEN & " " & GENERATE & " " & strCmd
  Debug.Print strCmd

  With CreateObject(WSCRIPT_SHELL)
    With .Exec(strCmd)
      GeneratePW = .StdOut.ReadAll
    End With
  End With

End Function
unfortunately we do not use bitwarden software, it is only used for the password generator as shown from the link
 

cheekybuddha

AWF VIP
Local time
Today, 14:33
Joined
Jul 21, 2014
Messages
2,288
unfortunately we do not use bitwarden software, it is only used for the password generator as shown from the link
Yes, the CLI program is a free download from the link I posted in Post #2.

However, I have just noticed it's 72MB unzipped!! :oops:
 

cheekybuddha

AWF VIP
Local time
Today, 14:33
Joined
Jul 21, 2014
Messages
2,288
@stu_c , do you have to use the bitwarden site?

If you can use another site like this one then you can use a simple http call like this:
Code:
Function MakeMeAPassword( _
           Optional WordCount As Integer = 3, _
           Optional blIncludeNumbers As Boolean = True, _
           Optional blCapitals As Boolean = True, _
           Optional NumberOfPassphrases As Integer = 1 _
         ) As String

  Const MAKE_ME_A_PASSWORD_API  As String = "https://makemeapassword.ligos.net/api/v1/"
  Const PASSPHRASE              As String = "passphrase"
  Const FS                      As String = "/"
  Const QMARK                   As String = "?"
  Const AMP                     As String = "&"
  Const PLAIN_FORMAT            As String = "plain"
  Const STRENGTH                As String = "s=Strong"
  Const PHRASE_COUNT            As String = "pc="
  Const WORD_COUNT              As String = "wc="
  Const SPACES                  As String = "sp=Y"
  Const MIN_CHARS               As String = "minCh="
  Const MAX_CHARS               As String = "maxCh=9999"
  Const NUMBERS                 As String = "nums="
  Const WHERE_NUMS              As String = "whenNum=EndOfWord"
  Const UPS                     As String = "ups="
  Const WHERE_UPS               As String = "whenUp=StartOfWord"
    Dim webServiceURL           As String
    Dim params                  As Variant
 
  params = Array( _
             STRENGTH, _
             PHRASE_COUNT & NumberOfPassphrases, _
             WORD_COUNT & WordCount, _
             SPACES, _
             MIN_CHARS & (5 * WordCount), _
             NUMBERS & IIf(blIncludeNumbers, "1", "0"), _
             WHERE_NUMS, _
             UPS & IIf(blIncludeNumbers, WordCount, "0"), _
             WHERE_UPS _
           )
  webServiceURL = MAKE_ME_A_PASSWORD_API & PASSPHRASE & FS & PLAIN_FORMAT & QMARK & Join(params, AMP)
  Debug.Print webServiceURL
  MakeMeAPassword = HTTP_Get(webServiceURL)

End Function

Function HTTP_Get(webServiceURL As String) As String

  Const XMLHTTP             As String = "MSXML2.ServerXMLHTTP", _
        METHOD_GET          As String = "GET", _
        HTTP_STATUS_SUCCESS As Integer = 200
    
  With CreateObject(XMLHTTP)
    .Open METHOD_GET, webServiceURL, False
    .Send
    If .Status = HTTP_STATUS_SUCCESS Then
      HTTP_Get = .ResponseText
    Else
      Err.Raise vbObjectError + .Status, , .Status & ": " & .StatusText
    End If
  End With
 
End Function
 

stu_c

Registered User.
Local time
Today, 14:33
Joined
Sep 20, 2007
Messages
489
@stu_c , do you have to use the bitwarden site?

If you can use another site like this one then you can use a simple http call like this:
Code:
Function MakeMeAPassword( _
           Optional WordCount As Integer = 3, _
           Optional blIncludeNumbers As Boolean = True, _
           Optional blCapitals As Boolean = True, _
           Optional NumberOfPassphrases As Integer = 1 _
         ) As String

  Const MAKE_ME_A_PASSWORD_API  As String = "https://makemeapassword.ligos.net/api/v1/"
  Const PASSPHRASE              As String = "passphrase"
  Const FS                      As String = "/"
  Const QMARK                   As String = "?"
  Const AMP                     As String = "&"
  Const PLAIN_FORMAT            As String = "plain"
  Const STRENGTH                As String = "s=Strong"
  Const PHRASE_COUNT            As String = "pc="
  Const WORD_COUNT              As String = "wc="
  Const SPACES                  As String = "sp=Y"
  Const MIN_CHARS               As String = "minCh="
  Const MAX_CHARS               As String = "maxCh=9999"
  Const NUMBERS                 As String = "nums="
  Const WHERE_NUMS              As String = "whenNum=EndOfWord"
  Const UPS                     As String = "ups="
  Const WHERE_UPS               As String = "whenUp=StartOfWord"
    Dim webServiceURL           As String
    Dim params                  As Variant

  params = Array( _
             STRENGTH, _
             PHRASE_COUNT & NumberOfPassphrases, _
             WORD_COUNT & WordCount, _
             SPACES, _
             MIN_CHARS & (5 * WordCount), _
             NUMBERS & IIf(blIncludeNumbers, "1", "0"), _
             WHERE_NUMS, _
             UPS & IIf(blIncludeNumbers, WordCount, "0"), _
             WHERE_UPS _
           )
  webServiceURL = MAKE_ME_A_PASSWORD_API & PASSPHRASE & FS & PLAIN_FORMAT & QMARK & Join(params, AMP)
  Debug.Print webServiceURL
  MakeMeAPassword = HTTP_Get(webServiceURL)

End Function

Function HTTP_Get(webServiceURL As String) As String

  Const XMLHTTP             As String = "MSXML2.ServerXMLHTTP", _
        METHOD_GET          As String = "GET", _
        HTTP_STATUS_SUCCESS As Integer = 200
   
  With CreateObject(XMLHTTP)
    .Open METHOD_GET, webServiceURL, False
    .Send
    If .Status = HTTP_STATUS_SUCCESS Then
      HTTP_Get = .ResponseText
    Else
      Err.Raise vbObjectError + .Status, , .Status & ": " & .StatusText
    End If
  End With

End Function
Hello,
Unfortunately at present we do! :(
 

cheekybuddha

AWF VIP
Local time
Today, 14:33
Joined
Jul 21, 2014
Messages
2,288
Unfortunately at present we do! :(
I would have a word with the powers that be.

Since IE is being replaced by MS on windows boxes, using CreateObject("InternetExplorer.Application") will start failing soon (if it hasn't already).

Also, the bitwarden pw generator site relies heavily on javascript which makes it really awkward to scrape from VBA.
 

isladogs

MVP / VIP
Local time
Today, 14:33
Joined
Jan 14, 2017
Messages
18,246
If it becomes an option to use different software, I also have a customisable password generator available as part of my app

The ACCDE version is free. Small charge if you want the source code
 

Users who are viewing this thread

Top Bottom