Hi,
I have a diagram which has annotation to shapes like
"[80010_1] Please listen carefully and confirm you made the following transaction. Please confirm the following Payment ".
I need to extract the annotation without the strike-through text and should enter that to a file.
The Resulting text should be "[80010_1] Please listen carefully and confirm the following Payment."
How to do this using VBA Macros?
Normally you could access a shape's text via the Text-property and be done with it. But in your case that won't work. I guess you have to use the characters object of the shape, and try to identify the strike-through parts of the text.
http://msdn.microsoft.com/en-us/library/aa342189%28v=office.12%29.aspx
And the corrosponding rows in the ShapeSheet:
http://msdn.microsoft.com/en-us/library/office/ff769034%28v=office.15%29.aspx
Thanks but I still dont get it. Can you pls tell me how to do this? Im breaking my head.
You can do it like this. Don't forget you may have to remove multiple spaces between the words.
Public Sub removeStrikeThrough( _
ByRef vsoshape As Visio.Shape)
Dim i As Integer
Dim strText As String
Dim endPos As Integer
Dim startPos As Integer
With vsoshape
startPos = 0
For i = 0 To .RowCount(visSectionCharacter) - 1
endPos = CharacterFormatEnd(vsoshape, startPos)
If .CellsSRC(visSectionCharacter, i, visCharacterStrikethru).ResultIU = 0 Then
strText = strText + Mid$(.Text, startPos + 1, endPos - startPos)
End If
startPos = endPos
Next
End With
Call MsgBox(strText)
End Sub
Private Function CharacterFormatEnd(visShape As Visio.Shape, ByVal iBegin As Integer) As Integer
Dim visChars As Visio.Characters
Dim iLen As Integer, i As Integer, iFirstRow As Integer, iRow As Integer
iRow = -1
iLen = Len(visShape.Text)
For i = iBegin To iLen
Set visChars = visShape.Characters
visChars.Begin = i
visChars.End = i + 1
If iRow = -1 Then iFirstRow = visChars.CharPropsRow(visBiasLeft)
iRow = visChars.CharPropsRow(visBiasLeft)
If iRow <> iFirstRow Then
'The row changed. We're done.
CharacterFormatEnd = i
Exit Function
End If
Next
CharacterFormatEnd = Len(visShape.Text)
End Function
Thanks Andy but it did not work for me.
My Annotation has the following text.
IF<GRETT_MSG>
[10000_n] <GREETING> message for...
PlayContact <CONTACT_FORMAL_1>
If ($numContacts > 1) {
[10010] ... or ...
PlayContact<CONTACT_FORMAL_2> }
If <GREET_TELEMARKETING_MESSAGE> == yes {
[10015] This is not a telemarketing call. }
[10020_n] ...<PLAY_MENU>, please press 1.
please press 1.
I want the strike-through text " [10020_n] ...<PLAY_MENU>, please press 1."
to be removed and the rest of the text should be printed as follows
IF<GRETT_MSG>
[10000_n] <GREETING> message for...
PlayContact <CONTACT_FORMAL_1>
If ($numContacts > 1) {
[10010] ... or ...
PlayContact<CONTACT_FORMAL_2> }
If <GREET_TELEMARKETING_MESSAGE> == yes {
[10015] This is not a telemarketing call. }
please press 1.
In your block of code
Set visChars = visShape.Characters the visChars is always "". the characters are not being fetched from annotation text.
How about a sample diagram.
Hi Andy,
I have attached the sample diagram.
I've added it as a double click on your annotation. The annotation is a grouped shape, so the text is on one of the sub-shapes, not the top level shape.
Excellent Andy and Thanks a Lot.
I made a single change in your code.
endPos = CharacterFormatEnd(vsoSubShape, startPos).
Im so happy.. Thanks again.
Just an idea, but I would have tried to use MS Word's capabilities to replace formated text in a string.
(Despite this solution would have been far less elegant than Andy's)
Hi Andy,
Thank you for your Code.
But Unfortunately it has some error. :(
I have attached file. I tried on that.
Can you help me to correct it
Browser ID: smf
(is_webkit)
Templates: 1:
Printpage (default).
Sub templates: 4:
init,
print_above,
main,
print_below.
Language files: 1:
index+Modifications.english (default).
Style sheets: 0:
.
Hooks called: 75 (
showintegrate_autoload, cache_get_data, integrate_pre_load, integrate_load_session, integrate_verify_user, cache_get_data, integrate_user_info, integrate_load_board, cache_get_data, integrate_board_info, cache_get_data, integrate_allowed_to_general, integrate_allowed_to_general, integrate_boards_allowed_to, integrate_mod_cache, integrate_allowed_to_general, integrate_pre_load_theme, cache_get_data, integrate_allowed_to_general, integrate_simple_actions, integrate_allowed_to_general, integrate_load_theme, integrate_pre_log_stats, cache_get_data, integrate_actions, integrate_pre_parsebbc, integrate_bbc_codes, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_menu_buttons, integrate_current_action, integrate_theme_context, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general)
Files included: 25 - 925KB. (
show/home/iw0lkfe3x6cq/public_html/vgforum/index.php, /home/iw0lkfe3x6cq/public_html/vgforum/Settings.php, /home/iw0lkfe3x6cq/public_html/vgforum/cache/db_last_error.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/QueryString.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Auth.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Errors.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Load.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Security.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Compat.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Db-mysql.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApi.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApiInterface.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/APIs/FileBased.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Charset.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/Metadata.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/QuickCheck.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Session.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Logging.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Class-BrowserDetect.php, (Current Theme)/languages/index.english.php, (Current Theme)/languages/Modifications.english.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Printpage.php, (Current Theme)/Printpage.template.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/CaseUpper.php)
Memory used: 764KB.
Tokens:
post-login.
Cache hits: 8: 0.00109s for 22,302 bytes (
showget modSettings: 0.00041s - 19983 bytes, get known_languages: 0.00016s - 1277 bytes, get board_parents-0: 0.00011s - 2 bytes, get permissions:-1: 0.00008s - 50 bytes, get theme_settings-1: 0.00012s - 980 bytes, get hostlookup-216.73.216.125: 0.00001s - 0 bytes, get log_online-update: 0.00019s - 10 bytes, get menu_buttons--1-english: 0.00002s - 0 bytes)
Cache misses: 2: (
showget hostlookup-216.73.216.125, get menu_buttons--1-english)
Queries used: 11.
[Show Queries]