locked
creating a pdf file using userform data RRS feed

  • Question

  • Hi,

    i have a usrform with 400 controls. Once the data entered in userform i would like to create a PDF file once click the command button. Could you please some help on this?

    regards

    Prathap

    Monday, April 8, 2013 7:09 AM

All replies

  • Transfer the data from the userform to a Word document, laid out as you require e.g. by using docvariable fields then save the document as a PDF.

    or

    Buy a copy of Adobe Acrobat and create a PDF form.


    Graham Mayor - Word MVP
    www.gmayor.com

    Monday, April 8, 2013 8:44 AM
  • Hi Graham, Thanks for your responce. But i would like to see all controls from Userform to Word i mean just want to copy and paste the complete userform in Word. I knew we can do the using print screen but the problem here when we use printscreen it will copy only some part os userform but i need complte userform as it's have scroll bar. If you have a code, could you please share it to me?

    Monday, April 8, 2013 9:28 AM
  • The essential method of transferring userform data to a Word document is covered at http://www.gmayor.com/Userform.htm  .

    If you want to capture a scrolling window then investigate SnagIt.


    Graham Mayor - Word MVP
    www.gmayor.com

    Monday, April 8, 2013 9:35 AM
  • You could try something like this

    Private Declare Sub keybd_event Lib "user32" ( _
                                         ByVal bVk As Byte, ByVal bScan As Byte, _
                                         ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Const VK_SNAPSHOT    As Long = &H2C '44
    Private Const VK_LMENU As Long = &HA4 '164
    Private Const KEYEVENTF_KEYUP As Long = 2
    Private Const KEYEVENTF_EXTENDEDKEY As Long = 1
    
    Private Sub UserForm_Click()
    Dim sngScrollTop As Single
    Dim sngScrollHt As Single
    Dim sngLt As Single
    Dim sngTp As Single
    Dim sngHt As Single
            With Me
                 sngScrollTop = .ScrollTop
                 sngScrollHt = .ScrollHeight
                 sngLt = .Left
                 sngTp = .Top
                 sngHt = .Height
                 .Left = 0
                 .Top = 0
                 .Height = .ScrollHeight
                 .ScrollTop = 0
                 DoEvents
                    keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY, 0&
                 keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0&
                 keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY Or
    KEYEVENTF_KEYUP, 0&
                 keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP,
    0&
                 DoEvents
                    Selection.Paste
                 sngScrollTop = .ScrollTop
                 sngScrollHt = .ScrollHeight
                 .Height = sngHt
                 .ScrollHeight = ScrollHeight
                 .ScrollTop = sngScrollTop
                 .Left = sngLt
                 .Top = sngTp
         End With

    If even after doing all in the above the form is too big to fit on the screen you could take a series of screenshots, each time increment the .ScrollTop value by an appropriate amount until you've got it all. You could restrict the form's less than the screen's height' height, rather than extending to the full height as above.

    Peter Thornton

    Monday, April 8, 2013 12:58 PM