How to work with powerful Ink Control using VBA. VBA Handwriting Recognition Office

How to work with powerful Ink Control using VBA. VBA Handwriting Recognition Office Hey everyone welcome back to my channel i'm lung pamai and in this video i'll show you how to work with ink controls using vba there are two types of controls which are ink added and ink picture which enables you to easily add ink and handwriting recognition to your projects or applications the ink edit controls has managed active x and 32-bit versions while the ink picture has only the manage ink picture and activates versions we are going to be.

Looking at the activex versions uh the main two difference between these two controls are that the ink edit control saves ink as text by default and then the picture saves ink as an ink data yeah okay so before we begin if you haven't please do not forget to subscribe and leave a like to support the channel also to improve the algorithms for the channel thanks okay let me add a new workbook in case you've never worked with ink controls you can enable the draw tab by going to your customized ribbon.

And just check this box okay and then you should be able to see this ribbon tab here um so very simple before we move on to the user form you can select uh you know like the pen the highlighter you can customize it as well by going here you can change the color the size and everything yeah and the effect so once you have that selected um for example you can choose the drill and then for example you just maybe take its signature that becomes um once you hit escape it becomes part.

Of the image yeah and the picture again is saved as ink data and then for example you can also add more pen you can erase uh for example you can erase it like this if you have uh drawn something you can also for example select like this and delete it as well okay and then for example this this one is different color similarly smaller in size yeah this one is for highlighting and so on um you can also insert.

Uh so once you're done hit escape to get out of that mode and once you are here for example you can insert a math as well for example um y is equal to um and plus 1 to the power of 2 and then maybe divided by 2. so once you have something like this you can insert uh which is very useful to represent yeah and then uh that's pretty much uh here that i want to show um.

So let's go quickly to word document as well you can go here and insert something like this a signature yeah for example by going here insert activex controls you can scroll down and find this there's two one is the ink added and then one is the picture so the one i have here is uh our pictures okay um and the way you utilize it in your vba is same so uh whatever i demonstrate in excel is gonna be uh.

How to work with powerful Ink Control using VBA. VBA Handwriting Recognition

You can use that as well in word document okay okay let me save this uh ink version one and let's start working with the user phone now i'm gonna insert a new user phone okay here uh in case you don't see this uh these controls what you can do is first you can you know like bring this toolbox you can go here and find the toolbox from here as well and right click on this toolbox.

Additional controls and find microsoft ink edit and ink picture after that click on ok you should be able to see these two new controls first let's start with ink um added yeah by default it has this text you can remove that in case you want to use this as a text box um the font uh we can increase a bit maybe bold we can access all this from the code as well okay so for example like this all right now let's bring in one button.

Or we can just have this loaded in initializer but in case you know like if there are beginners following let me put a button so when this button is clicked it will add a text here and color it and so on so let's say uh ink edit one dot six we'll do hello world okay now let's say that you want to highlight this first part second part with different color you can do so.

Dot select start maybe from zero and then dot select length so basically we are telling the code to select like this and put a color to do and then dot select color is equal to maybe green you can put rgb as well yeah so this part is different color now uh we can replicate this block quickly so starting from maybe six or seven until we can get the len as well using the.

Length function but let me just put it like this maybe blue okay so that's how you can set um you know i write put a text i will go you know like more advanced um so for example this is right if you have to read you can simply um use message box you can write this value as well to your workbook so in case you do that you are going to refer in this uh inc.

Edit1.txt there are more properties as you can see uh here ctrl tip source uh there are so many of them that you can you know manipulate we'll touch base on more of those okay so f5 hello world uh it returns the value so i'm going to change this to read and let's bring it up here for now okay save this.

    Now i'm gonna add another one now i'm gonna demonstrate how to copies you know like uh cell

    Range or objects from your excel sheet and then have it populated here having all the colors and all this intake yeah so let me bring another edit box again as a demonstration i'm going to leave everything as default i'll just get rid of this text all right um.

    Okay i want to save this as macro enabled and let me add one more button for demonstration now before we begin uh this we will reuse the api that we use for our vbe code automation so i'm gonna leave the link for this blog just go and copy this entire code we just need to use a set to clipboard and.

    We want to use this based object okay so copy this and bring it inserted in module module and for this one we want to use it from the user form as well so we'll make it to public and this one as well for okay now uh once you have this again we'll just need this um yes so going back to user form uh let's say um populate.

    For example um inc added so first let's uh copy this demo from here to you know like to the edit box okay all these objects uh let's start with a range so let's say that we have a range here again hello world something like that or i think we can reuse some of this because our edit box uh ink edit is white in color.

    So maybe we can add something like this as an example first let's add this um something which is not maybe all these are white fonts so i'm just trying to get a good example but anyways let's say that this is black in color and the bike is like this um so i'll say um range whatever the trains is selected.

    Or here it goes your cell address okay and dot copy um and then we'll use paste this and then we'll paste this to our ink edit to dot and then we'll get the handle and then we want to clear the clipboard okay so let's give it a try um f5 yeah so.

    Here comes our you can also write here which i'll demonstrate this in a bit uh okay so that's how you can populate the cell in case you have to copy the entire range for example we can reuse set the clipboard as well here so for example set the clipboard equal to uh range example and let's say that we want to copy um this range.

    From b2 until b6 yeah so b2 to b6 and then uh we want to paste this i'm just setting a text that we we are setting this to clipboard for example if i put this and run this code it's there in the clipboard now like this yeah so i'm putting in the clipboard and then we are pasting it into our control next i'm copying the range and then pasting it again okay so let's try.

    Okay so put this and then next it says range example maybe we can use here maybe a new line let's see if this works if we want to have this in the new line okay so this works um okay so that's example of range first is the cell the range and then.

    Range copied here now let's say we want to copy um

    Let's say we want to copy a table let me just quickly put a table here run between this to this okay and maybe something like that and this table name is table two so we will just.

    Use the list object method together um so here i will say active sheet dot list object and then our table dot copy uh and this just give me a moment um this object dot okay we cannot directly.

    Copy the table so we have to do the range yeah so the table is there uh maybe we can just put this example here table okay so now we cannot see the table we can add the scroll bar here as well where is the scroll bar maybe vertical okay so um i really do not encourage.

    Doing a dashboard and all in the user form but if you have to complete something colorful um i think this will be the easiest way other rather than exporting it to the directory and bringing it back into user form on runtime i think this will be the faster way to do it okay so now um we can also put a chart so let's get the name of this chart let's say we want to bring this one.

    The name of this chart is this i'm going to copy this okay going back to our code now this one is going to be chart these are basically just putting like a header so that we can refer to it and this one is going to be instead of this object it's going to be chart.

    Objects um just give me one second okay i forgot to remove this that was for table okay so here comes our chart um so single cell range stable chart we can also um directly copy range and then we can paste it as a snapshot so ins for example like here we did arrange right we can simply replicate this part.

    Uh range to a picture i would say and then here um dot copy picture we can use this method and now if i run this there is this but this is a snapshot okay other than that if you look here you can still edit this data here if you see similarly these ones that we pasted can be edited here but the one that is pasted here down in.

    Snapshot we cannot edit that okay becomes a snapshot picture okay so that will be um for example um if you have to you know copy the data from excel and populate that in your interior in added control okay so for example now let's see that we want to have a you want to have the to enable uh the mouse input you can send that up.

    As well so um and then we can enable this here we'll just say ink edit control one two dot use mouse for input equal to true okay so let me populate this first and let's say that we want to populate something here um we can write here for example um hello let's give it a moment and then here comes our hello it's.

    Uh white in color so we can see it uh maybe we can try and insert here so i'll select this and i'll say 1000 yeah so that's how you can do it as well you can change the mode of insert as well but uh for now that part i'll just leave it because it's very simple um i think now we can move to the picture for picture i'm going to insert a new.

    Ink picture i'll insert a new one and bring back the two box and i'm gonna insert this ink just make it smaller like this okay and then i'm gonna load it up so once you load it up you are able to draw uh anything here yeah um so in case you have to um change the mode that you want to do.

    Certain things here um let me just maybe insert a frame maybe here for example and we'll have a option buttons so that we can do in like some change the mode of the you know the picture so let's say this one is to draw or basically here and then this one is the delete.

    Like the one we saw there yeah and this one is to select let's keep it simple um so first one will be ink picture one dot edit mode is equal to first is inc and then second one is delete and third one.

    Is to select okay so if i do this now and say delete i can drop it if i draw i can say select and then delete it something like that yeah now i'll show as well how to uh read the ink data for this export then export this as a picture somewhere else in case you are taking this as a signature in your uh in your project you might.

    Want to save this data uh in like the ink data or you might want to export this as a picture so i'll quickly demonstrate that as well um okay in case we want to clear this we can do that as well or we can have a button for that let's say clear something like that i'm not gonna spend too much time to make this look good i'll just demonstrate this only okay so this.

    Um dot inc dot delete strokes oh no delete um what is strokes okay one second looks like there's some memory problem let me see if this is a new file just in case it crashes.

    Okay uh i think i just need to repaint the phone made audrey paint okay so it clears the thumbnail okay so draw delete and select yeah now you can also change the color uh basically you can change.

    The attribute of this i'll quickly demonstrate that as well uh put the new button here let's see um i'll just call this attribute attribute set or something like that now for this um dot default attributes dot color let's say we want to set a color uh we can set this to um let's say red again we'll we can use the rgb you can use the other color codes as well so if i run.

    This now it's black if i set the attribute click on red yeah um so yeah you can use rgb and then here you can put our red green and blue combinations okay for example something like that and then let's continue this dot attribute dot uh we you can set the width and the height of the you know like 10 as well so for example let's say i want to make it bigger.

    The height as well so normal by default then if i set the attribute becomes bigger yeah again if i want to set this to blue you can see blue okay you can also reduce it a lot yeah um what else can we do .

    Uh okay you can set the uh pen tip type as well okay uh using this i think we can just re use this block let me just get rid of this let's say this pen tip we want it to be a one is rectangle and then i'm just gonna type half and then another one of the people.

    Pen tip equal to rectangle and then if we click on this we want to set the pen tip equal to ball yeah so draw a rectangle here and then ball setting the attributes i think we can make the attributes a bigger so that we are able to see it i'm sorry.

    As you can see it's it has turned into rectangle box yeah and then i've said this become ball okay all right um now uh let's give me one second let's say that um you can also uh simply use the you know like uh said the high contrast you can also take care of the pressure uh pen pressure and all this okay so you can just access that from the properties now in case you want to export this um.

    You know like uh the picture uh in the control to your worksheet we can also do that and then we can also export it to a directory so let me first demonstrate how to do this uh in the into this particular worksheet let's say that we want to export it here okay p2 uh let me copy this and we'll say export to worksheet and then second one we'll do export to the directory and maybe we'll do another.

    Example where we read inc and then we also populate a new picture uh using ink yeah so we'll do that example as well uh so first export to this to the worksheet okay um so we'll say ink picture one dot ink dot copy the clipboard.

    Clip or copy okay so we're basically copying it and now we'll say our range p1 this will select range p1 b2 sorry and then we'll paste it there paste and then once we paste then we will automatically have the image selected now we can say that the image basically is going to be the shape we'll say uh set image equal to.

    Whatever was pasted at that time and then um we can set the width the height and all this uh using this object once it's pasted so with this image dot top equal to 100 something like that and dot left equal to 100 okay so let's try this first um so let's say that this is some signature.

    Export to sheet yeah so that is how you can do it it's quite simple um see okay um now let's see that you want to export this to uh directory uh we have done this example a similar example i think in powerpoint as well and in our progress bar in ui and ux series so but i'll quickly demonstrate this one as well so for this we are gonna um.

    Transfer the data in bytes and then we are gonna see this there um to our directory so let's call this uh image data as image data is gonna be in array okay as byte and then um first again we will use this image we just have one image now so okay um so it may stay down.

    DISCLAIMER: In this description contains affiliate links, which means that if you click on one of the product links, I'll receive a small commission. This helps support the channel and allows us to continue to make videos like this. All Content Responsibility lies with the Channel Producer. For Download, see The Author's channel. The content of this Post was transcribed from the Channel: https://www.youtube.com/watch?v=ok8jcTaelNc
Previous Post Next Post