title: Using PDFCreator to convert docx to pdf in a VB .NET function but it's not working
body: <p>I have a VB .NET function and I need to convert a .docx document to .pdf using that function. What I'm doing is I'm using PDFCreator from commandline with a batch created and executed inside my VB .NET function, but somehow it's not working and I have no idea what is it that I'm doing wrong.
  Any suggestions?
  Forgot to say that I need this process to be completely hidden from user interacting with the application, so the conversion to .pdf must be automatic, without user interaction. The user only needs to click "Convert" and the function should do the rest.</p>
  
  <pre><code>Public dirTemp As String = My.Computer.FileSystem.SpecialDirectories.Temp
  ----
  Function GeneratePDF_W10(ByVal PathWord As String, PathPDF As String)
      Try
          Dim pathScriptPDF As String = dirTemp &amp; "\PDFScriptW10.bat"
          Dim write As New System.IO.StreamWriter(pathScriptPDF, False)
  
          write.WriteLine("C:\Program Files\PDFCreator\PDFCreator.exe /InitializeSettings")
          write.WriteLine("C:\Program Files\PDFCreator\PDFCreator.exe /PrintFile=""" &amp; PathWord &amp; """ /OutputFile=""" &amp; PathPDF &amp; """")
  
          write.Close()
  
  
          Process.Start(pathScriptPDF)
  
          Dim count As Integer = 0
  
          Do While Exists(PathPDF) = False
              Threading.Thread.Sleep(1000)
              count = count + 1
              If count &gt;= 60 Then Exit Do
          Loop
  
          If Exists(PathPDF) = True Then
              Return 1
          Else
              Return 0
  
          End If
  
      Catch ex As Exception
          MessageBox.Show(ex.Message)
  
          Return 0
      End Try
  
  
  End Function
  </code></pre>