title: Excel VBA UserForm printscreen save as pdf
body: <p>I have UserForm where I have button to take print screen of UserForm, paste to newly created worksheet and export it as pdf. Problems I have with current code are:</p>
  
  <p>1) I want to fit print screen to one page, now it takes print screen and splits to two pages. </p>
  
  <p>2) Higher resolution of print screen. Is it possible to increase resolution of print screen for more higher quality?</p>
  
  <p>Code I use for button on UserForm:</p>
  
  <pre><code>Private Sub btnPrintPDF_Click()
  'change to your button name
      Dim pdfName As String
      Dim newWS As Worksheet
  
      Application.DisplayAlerts = False
  
      keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY, 0
      keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0
      keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
      keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
  
      DoEvents 'Otherwise, all of screen would be pasted as if PrtScn rather than Alt+PrtScn was used for the copy.
  
      Set newWS = ThisWorkbook.Worksheets.Add(After:=Worksheets(Worksheets.Count))
      newWS.PasteSpecial Format:="Bitmap", Link:=False, DisplayAsIcon:=False
      pdfName = ThisWorkbook.Path &amp; "\" &amp; Sheets("MAIN").Range("D14").Value &amp; "Project_Summary" &amp; "_" &amp; " " &amp; Format(Now, "yyyy-mmm-dd") &amp; ".pdf"
      newWS.ExportAsFixedFormat Type:=xlTypePDF, _
          FileName:=pdfName, Quality:=xlQualityStandard, _
          IncludeDocProperties:=False, IgnorePrintAreas:=False, _
          OpenAfterPublish:=False
      newWS.Delete
      Unload Me
      Application.DisplayAlerts = True
      ThisWorkbook.Sheets("MAIN").Activate
  End Sub
  </code></pre>