Hi All
I am working on a few VBA codes, and I am looking into using Objects to hopefully get over one of the hurdles I'm facing.
I have not used Objects myself personally before and after googling around what I have read about Objects is confusing as hell haha.
Just wondering if someone can walk be through in real simple terms how to create an object...
Basically what I want to do is create an object with the this code in it:
This code simply generates a string based on the co-ordinates the cursor is at.
I want to put this into an object because I'm hoping this will make my other code (which needs to call the string from the cursor co-ordinates) able to work and making the Cursor co-ordinates update each time the object is called.
I have tried a simple Dim statement with the .GetText command, but it never updates the cursor position, its sets the cursor position from the moment you run the macro, where as it needs to update based on a new cursor position each time I need to use that string.
Anyway after reading around and a few trials and errors I just don't understand how to do this, I have created a Class (called Class1) and put the above .GetText code in it.
Then in my normal Sub, I have used the following:
I'm hoping to run
Command after each time I need the string, so that hopefully it refreshes the cursor position since I clear the data for the object?
This is what I got from reading around, but its obviously wrong and I'm missing something important, however all the examples I can find are trying to make complicated objects, where as mine is really simple...
Any help would be greatly appreciated.
Thanks
I am working on a few VBA codes, and I am looking into using Objects to hopefully get over one of the hurdles I'm facing.
I have not used Objects myself personally before and after googling around what I have read about Objects is confusing as hell haha.
Just wondering if someone can walk be through in real simple terms how to create an object...
Basically what I want to do is create an object with the this code in it:
Code:
.GetText(CursorRow, CursorColumn, CursorRow, CursorColumn + 1)
This code simply generates a string based on the co-ordinates the cursor is at.
I want to put this into an object because I'm hoping this will make my other code (which needs to call the string from the cursor co-ordinates) able to work and making the Cursor co-ordinates update each time the object is called.
I have tried a simple Dim statement with the .GetText command, but it never updates the cursor position, its sets the cursor position from the moment you run the macro, where as it needs to update based on a new cursor position each time I need to use that string.
Anyway after reading around and a few trials and errors I just don't understand how to do this, I have created a Class (called Class1) and put the above .GetText code in it.
Then in my normal Sub, I have used the following:
Code:
Dim xyz As Class1
Set xyz = New Class1
I'm hoping to run
Code:
Set xyz = Nothing
Command after each time I need the string, so that hopefully it refreshes the cursor position since I clear the data for the object?
This is what I got from reading around, but its obviously wrong and I'm missing something important, however all the examples I can find are trying to make complicated objects, where as mine is really simple...
Any help would be greatly appreciated.
Thanks