isnoend2001
asked on
RichTextBox check if .seltext contains an image
Hi Experts
How can i find if .seltext contains an image?
I have tried the following:
When viewed in break test= " " 4 spaces
MsgBox VarType(test)<- This returns a 8 = string
x = Len(myrtf1.SelText)<-This always returns 4
How can i find if .seltext contains an image?
I have tried the following:
When viewed in break test= " " 4 spaces
MsgBox VarType(test)<- This returns a 8 = string
x = Len(myrtf1.SelText)<-This always returns 4
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thank you
I think another way is to use a hidden RichTextBox and copy there the SelRTF of the original control and then loop through the objects:
HiddenRichTextBox.TextRTF = OriginalRichTextBox.SelRTF
Dim O As RichTextLib.OLEObject
For Each O In HiddenRichTextBox.OLEObjec ts
If O.Class = "StaticMetafile" Then
'This is a picture, increase counter
CountP = CountP + 1
End If
Next
I think another way is to use a hidden RichTextBox and copy there the SelRTF of the original control and then loop through the objects:
HiddenRichTextBox.TextRTF = OriginalRichTextBox.SelRTF
Dim O As RichTextLib.OLEObject
For Each O In HiddenRichTextBox.OLEObjec
If O.Class = "StaticMetafile" Then
'This is a picture, increase counter
CountP = CountP + 1
End If
Next
ASKER
Thanks
What you already provided worked fine. I only need to check the last line in seltext. Here's why
I made a sectioned rtf file with end of section string and then the name of the section taken from a combo box appended
to the end of the end of section. This provided me with 1 rtf file instead a lot of rtf files. Everything worked fine until i
discovered that if the last string in the section was bulleted it would put a few litttle dots at the end the section. I tried to
overcome this by when saving turning off the bullets like selbullet=False. Can't remember why, but this did not work.
So i decided to check the last row after opening for isnumeric, strings and your image code. This seems to get rid of the little bullets and solve the problem
What you already provided worked fine. I only need to check the last line in seltext. Here's why
I made a sectioned rtf file with end of section string and then the name of the section taken from a combo box appended
to the end of the end of section. This provided me with 1 rtf file instead a lot of rtf files. Everything worked fine until i
discovered that if the last string in the section was bulleted it would put a few litttle dots at the end the section. I tried to
overcome this by when saving turning off the bullets like selbullet=False. Can't remember why, but this did not work.
So i decided to check the last row after opening for isnumeric, strings and your image code. This seems to get rid of the little bullets and solve the problem
ASKER
You are the man!, just what i was looking for