As part of a application I am developing, I added a command button on a form that will send the customers Name and Address to a word template letter that gets mailed to them.
This is the code I am using for this part of the process:
Dim fullname As String, commaposition As Integer
fullname = "aabbccddeeffgg, aabbccddeeffgg"
fullname = Left(fullname, 14)
.ActiveDocument.Tables(2).Cell(1, 1).Select
.Selection.Text = Left(CStr(Forms!frm_Main!CHName), 4)
The format of the names look like:
LastName, FirstName Middle Initial.
Smith, John A
The code I pasted above (obviously) returns the first 4 characters.
Since the names will vary in the length of characters, I need to get all the text after the comma for the FirstName and middle initial, and all the text before the comma for the LastName.
I declared commaposition As Integer, but I haven't figured out if that is the correct way to do this or how to use it.
I am pretty new to VBA and I am having a little difficulty with this, any help would be greatly appreciated. Thank you
This is the code I am using for this part of the process:
Dim fullname As String, commaposition As Integer
fullname = "aabbccddeeffgg, aabbccddeeffgg"
fullname = Left(fullname, 14)
.ActiveDocument.Tables(2).Cell(1, 1).Select
.Selection.Text = Left(CStr(Forms!frm_Main!CHName), 4)
The format of the names look like:
LastName, FirstName Middle Initial.
Smith, John A
The code I pasted above (obviously) returns the first 4 characters.
Since the names will vary in the length of characters, I need to get all the text after the comma for the FirstName and middle initial, and all the text before the comma for the LastName.
I declared commaposition As Integer, but I haven't figured out if that is the correct way to do this or how to use it.
I am pretty new to VBA and I am having a little difficulty with this, any help would be greatly appreciated. Thank you