Is there a way to create a prompt screen for a user to select a file

Welcome Forums General PowerShell Q&A Is there a way to create a prompt screen for a user to select a file

Viewing 1 reply thread
  • Author
    Posts
    • #202802
      Participant
      Topics: 5
      Replies: 4
      Points: 42
      Rank: Member

      So, im trying to put together a code that would convert a file from a pdf to a word. i figured out the word issue, thanks to help from the forum. My next question is it possible to create a prompt screen, that would direct a user to have to select a file to be converted?

    • #225186
      Participant
      Topics: 0
      Replies: 1
      Points: 5
      Rank: Member

      Yes, this will do that for selecting a PDF:

      Add-Type -AssemblyName System.Windows.Forms
      $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
       Multiselect = $false # Multiple files can't be chosen
       Filter = 'PDF Files (*.pdf)} | *.pdf' 
      }
      [void]$FileBrowser.ShowDialog()
      If($FileBrowser.CheckFileExists = $true) {
       $FileBrowser.FileName #Lists selected file. Do whatever here instead.
      }
Viewing 1 reply thread
  • You must be logged in to reply to this topic.