How to use VBIDE in VB6 Addin to programmatically print source code.?

How to programmatically print source code in VB6 Addin ..? There are no print or preview methods that I can find for VBIDE in the object browser.

I searched high and low on Google, and there is a strange lack of information about printing the code of the VBIDE module. I get a lot of hits for PrettyPrint, but that’s it. The disadvantage is so great that it makes me wonder if there is any fundamental concept that I am completely lacking.

I got scared of a copy of O'Reilly's book mentioned by Herb in https://stackoverflow.com/a/4646/ and he doesn't mention printing the source code. The only way I can see is to export the code into text files and print them using the usual means not related to VBIDE.

I also checked the Chip Pearson manual on VBE at http://www.cpearson.com/excel/vbe.aspx , which is almost identical to VBIDE, and there isn’t even a hint for printing the code, other than the idea I mentioned about saving to text files, and then about printing. A.

** Ideally, I would like to use the existing VB6 File> Print dialog, adding another additional flag to it. I understand that adding controls to an existing dialog is another topic, and I would not mind creating my own version of the print dialog. A.

+5
source share
1 answer

This is possible with the CommandBarButton and SendKeys proxies.

Getting the handle to the PrintBarControl command is quite simple, but clicking the button brings up a dialog in your path, so we must use SendKeys to set the parameters and submit the form ....

You can use code similar to the following:

Dim printCommand As CommandBarControl Set printCommand = Application.VBE.CommandBars.FindControl(ID:=4) printCommand.Execute 'Yep, SendKeys, erghhh Application.SendKeys "P" 'Force the whole project to print Application.SendKeys "{ENTER}" 
+2
source

Source: https://habr.com/ru/post/1261925/


All Articles