I'm trying to automate the creation of a Word document that includes, for each user form on a project a screen capture of the form followed by the user form's code.
No problems regarding the code part, I already did that.
For the screen capture part I had though of activating each form in turn and using code found here to capture the screen, but I get an error when I try to activate the form. The error reads: "Runtime error 438 Object doesn't support this propertyor method".
I'm using code like the following (sorry for lack of indenting, the post editor keeps removing it):
Private Sub cmdDocLight_Click() Const vb_ext_ct_MSForm As Byte = 3 Const vb_ext_ct_StdModule As Byte = 1 Const vb_ext_ct_Document As Byte = 100 Const vb_ext_ct_ClassModule As Byte = 2 Dim wkb As Workbook Dim VBComp As VBIDE.VBComponent Set wkb = Workbooks(cboLibros.Text) 'cboLibros holds a list of oppened workbooks For Each VBComp In wkb.VBProject.VBComponents If VBComp.Type = vbext_ct_MSForm Then VBComp.Show 0 '<- this line causes error. 'Code to capture the screen here. AltPrintScreen '<- haven't tested this routine, I'm stuck in preceding line Unload VBComp 'Code to paste the clipboard on the Word document will follow End If Next End Sub
Any help will be appreciated.
Thanks in advance,