-
ब्लॉग कोशिश कर रहा है بلاگز کی ک*Trying Blogs
Trying Blogs ब्लॉग कोशिश कर रहा है ബ്ലോഗുകൾ ശ്രമിക്കുന്നു
بلاگز کی کوشش کر رہے
The purpose of this Thread is the following:
इस धागे के उद्देश्य निम्नलिखित है:
ഈ ത്രെഡ് ഉദ്ദേശ്യം പിന്തുടരുന്നു:
:یہاں مقصد مندرجہ ذیل ہے
Codes and Information is here.
संहिताओं और सूचना यहाँ हैं।
കോഡുകൾ സമവാക്യങ്ങളേയും വിവരങ്ങൾ ഇവിടെ ഉണ്ട്.
کوڈز اور معلومات یہاں پایا جائے.
1)
To be referenced in this web site
इस वेब साइट में संदर्भित किया जा करने के लिए
ഈ വെബ് സൈറ്റിൽ പരാമർശിച്ചിരിക്കുന്ന ലഭിക്കണമെങ്കിൽ
ان خطوط اس ویب سائٹ سے محولہ کیا جائے گا
2)
Also to be referenced from other web sites
इसके अलावा अन्य वेब साइटों से संदर्भित किया जा करने के लिए
മറ്റ് വെബ് സൈറ്റുകളിൽ നിന്നുള്ള പരാമർശിച്ചിരിക്കുന്ന ചെയ്യുവാൻ
اس کے علاوہ دیگر ویب سائٹس سے محولہ کیا جا کرنے
_...........
This has been agreed with the Administrator
यह व्यवस्थापक द्वारा सहमति व्यक्त की है
ഈ അഡ്മിനിസ്ട്രേറ്റർ സമ്മതിച്ചു ഉണ്ടായിരുന്നു
یہ ایڈمنسٹریٹر کی طرف سے اس بات پر اتفاق کیا ہے
http://www.excelfox.com/forum/showth...eded#post10071
http://www.excelfox.com/forum/showth...age2#post10082
There are no restrictions on posting here
यहां पोस्टिंग पर कोई प्रतिबंध नहीं कर रहे हैं
ഇവിടെ പോസ്റ്റുചെയ്യുന്നതിന് നിയന്ത്രണങ്ങൾ ഒന്നുമില്ല
یہاں پوسٹنگ پر کوئی پابندی نہیں ہے
There is no time limit on Editing ( Only here in Test Sub Forum )
संपादन पर कोई समय सीमा नहीं है ( केवल परीक्षण उप फोरम में )
എഡിറ്റിംഗ് യാതൊരു സമയ പരിധിയുമില്ല ( മാത്രം ഉപ ഫോറം ടെസ്റ്റ് )
ترمیم پر کوئی وقت کی حد نہیں ہے
( صرف ذیلی فورم ٹیسٹ )
I will re use some posts. By Editing. There is no time limit on Editing
मैं फिर से उपयोग होगा कुछ पदों . बदलें संपादन . संपादन पर कोई समय सीमा नहीं है.
ഞാൻ ചില ഭാഗങ്ങളിൽ പുനരുപയോഗിക്കാൻ ചെയ്യും. എഡിറ്റ് സാധ്യമാണു് . എഡിറ്റിംഗ് യാതൊരു സമയ പരിധിയുമില്ല
ترمیم پر کوئی وقت کی حد نہیں ہے میں ترمیم کو استعمال کرتے ہوئے I ادلیکھت کبھی کبھی کریں گے بنانے کے.
Alan
:)
_.________________________________________________ _______________________
Quick links
Variable definitions : http://www.excelfox.com/forum/showth...0192#post10192
-
VBA Remove BB Code Code Tags in text
VBA Remove BB Code Code Tags in text
In the next post is a code to remove BB Code Code Tags in text
This code is slightly redundant since I was given a simpler one ,
http://www.eileenslounge.com/viewtop...202145#p202122
which probably is more Full proof !
But I include it here with description for future reference. I may use it in a following code or codes to cross check the results given.
The code is intended to remove valid BB Code Code Tag sections from a Text string.
In this case, valid means in terms of the syntax, which is basically as follows
[TagWord=Some]Any text[/TagWord] or [B]Any text[/b]
An arbitrary string is given initially in code section Rem 1)
"gggg[d=fg]2[/d]45[/8]x[ddd[Cl=XYZ][/Cl][B]Any text[/b]"
Then the main code is as follows
Rem 2 Brief Code description
The code works backwards 100 through the whole string. It looks at a character at a time.
120 __ On If finding a ] , it notes the position of it,
140 BcrdEEnd, then keeps going back.
160___If it finds another it notes that as the ] position and carries on going back.
170 It determines the position of a [ , BcrdESt, by looking for a [\
It starts looking again for the next ] ,
250 _____If a ] is found, it checks
260 _____If the next character back is another ], Then it keeps going back. If the next character back was Not a ] , then the position of the ], BcrdSEnd, is
270 noted
A new last loop 290 starts going further back to look for a [
300 ________If it finds a [ , it notes that, BcrdSSt.
320 ________If in the unlikely event that it is a start of an end , like [\ then we have found a second End BB Code Code Tag so we do like_..
BcrdEEnd = BcrdSEnd:
BcrdESt = BcrdSSt:
BcrdSEnd=0:
( BcrdSSt=0 )
_..and go back and start again looking for the start tag. Otherwise the start position of the start tag, BcrdSSt, is noted, then it is finally time to go and think about getting rid of the code tag pair whose positions have now been determined....
430 FkOffCrd:
_..So I come to a point, aptly named, Rem 3) "I think we come here with a complete set of 4 positions". So I try to take the BB Code Code Tags out. As I am going backwards, the new string with the missing Code Tag pair does not mess up me going through the characters as I took off stuff “behind me”
450 I overdo the use of variables here because I can and do, but also because a development of the code might be to look through a list of available BB Code Code Tags to check I have them . I do one quick validity check: I check that the word after the / in the End BB Code code tag is the same as the word in the start BB Code code tag ( that before an = , if there is an = ) . Only
500____ If this condition ( which must be met for a valid BB Code code tag ) is met are the pair of tags removed by replacing them with , . Another condition is also checked: a / in second character of the stop tag.
Either from going through a code section search with possible removal, or ,
540 Else not , we are at the Next posCurrent of the main going backward Loop,
580 , so keep going back looking for another, or a first possible start ( looking from the back ).
Hopefully, for example at line 340, posCurrent would have been reduce to allow for the inner Loops going back in a code tag section search.
_................................
The code returns the string:
gggg245[/8]x[ddd[B]Any text[/b]
-
Code described and ExPlained in last post
Code described and ExPlained in last post
:rolleyes: I just said that :)
Code:
Sub LongWayOfDoingIt()
10 Rem 1) Test string
20 Dim strBBCode As String '
30 Let strBBCode = "gggg[d=fg]2[/d]45[/8]x[ddd[Cl=XYZ][/Cl]]Any text"
40 Dim strRmveBBCode As String: Let strRmveBBCode = strBBCode ' This will be adjusted until finally has no BBCode tag pairs
50 Dim Lstr As Long ' This will be adjusted as necerssary for current length ' Long is very simple to handle, - final memory "size" type is known (123.456 and 000.001 have same "size" computer memory ) , and so a Address suggestion can be given for the next line when the variable is filled in. '( Long is a Big whole Number limit (-2,147,483,648 to 2,147,483,647) If you need some sort of validation the value should only be within the range of a Byte/Integer otherwise there's no point using anything but Long.--upon/after 32-bit, Integers (Short) need converted internally anyways, so a Long is actually faster. )
60 Let Lstr = Len(strBBCode)
70 Rem 2) Loop through and get a BB Code section
80 Dim strBBCodePair As String ' for a found valid pair '
' Prepares "Pointer" to a "Blue Print" (or Form, Questionaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular “Value”, or (“Values” for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. A String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quich checks.. But..http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring-2.html#post44116
90 Dim posCurrent As Long 'Current position in the string' Loop Bound variable Count '_-Main Loop==========================
100 For posCurrent = Lstr To 2 Step -1 'Important to go backwards as we chop off behind us so have a less complicated current position. We look at pos-1 in some code parts so we would error if we went back to less than 2
110 '2a) Check for a ] Most likely a end of end tag ' ---Loop To find ]
120 If Mid(strRmveBBCode, posCurrent, 1) = "]" Then
130 Dim posBBCodeTagSrch As Long '
140 Dim BcrdEEnd As Long: Let BcrdEEnd = posCurrent 'Position of possible End Code Tag End ' ---Loop To Find [/--
150 For posBBCodeTagSrch = posCurrent - 1 To 2 Step -1 'PosCurrent is set here at loop start. ###It is not effected by cardinally sining changing PosCurrent Loop Bound variable caount in Outer main Loop
160 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "]" Then Let BcrdEEnd = posBBCodeTagSrch: GoTo NxtCESPosPos ' If we hit another ] then change the stop tag stop character position and start again to see if is a valid BB code section
170 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "/" And Mid(strRmveBBCode, posBBCodeTagSrch - 1, 1) = "[" Then 'We hit start of a BB Code end tag
180 Dim BcrdESt As Long: Let BcrdESt = posBBCodeTagSrch - 1 'Position of End Code Tag Start
190 Exit For ' We leave this For the End Code Tag Start Search, Exit For with a [ at posBBCodeTagSrch-1
200 Else 'Not found start of end Tag or stop of end Tag.
210 End If
220 NxtCESPosPos: Next posBBCodeTagSrch ' go back in possible BB code string ' ---End Loop to find [/---------------------
230 If posBBCodeTagSrch = 3 Then Exit Sub 'case we never found the start of an End Code Tag
235 '2b) Check for a ] Most Likely end of start tag ' ---Loop to find ]
240 For posBBCodeTagSrch = posBBCodeTagSrch - 2 To 2 Step -1 ' Once again ### the start is set and fixed, the Loop Bound Variable Count will change
250 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "]" Then
260 If Mid(strRmveBBCode, posBBCodeTagSrch - 1, 1) = "]" Then GoTo NxtCSSPosPos ' If we hit another ] then start again to see if is a valid BB code start section
270 Dim BcrdSEnd As Long: Let BcrdSEnd = posBBCodeTagSrch 'Position of possible Start Code Tag End
280 Dim LTagStLoop As Long 'Last loop to find start of start Code Tag
290 For LTagStLoop = posBBCodeTagSrch - 1 To 1 Step -1 '_-Most Inner loop_______to find [/____________
300 If Mid(strRmveBBCode, LTagStLoop, 1) = "[" Then
310 Dim BcrdSSt As Long 'Have to put it here, - I may occaisionally have to set it to 0 in next line
320 If Mid(strRmveBBCode, LTagStLoop + 1, 1) = "/" Then Let BcrdEEnd = BcrdSEnd: Let BcrdSEnd = 0: Let BcrdESt = LTagStLoop: Let BcrdSSt = 0: Let posBBCodeTagSrch = LTagStLoop: GoTo NxtCSSPosPos ' Found a second end Code Tag. So change the previous found start and stop , and adjust the Loop Bound variable Count appropriately for a new search for a start Code Tag
330 Let BcrdSSt = LTagStLoop
340 Let posCurrent = BcrdSSt 'End of Code Tag section search
350 GoTo FkOffCrd ' We leave this For the start Code Tag Start Search and go to Fuk Off Crd:
360 Else ' Still looking for start of start Code Tag
370 End If
380 Next LTagStLoop '_- End Most inner loop_____________________to find [/_____________________________
390 If LTagStLoop = 1 Then GoTo TheEnd 'Case I think we failed to find a start start [ for the complete possible Code Tag section search
400 Else 'Not found end of start Tag or start of start Tag
410 End If
420 NxtCSSPosPos: Next posBBCodeTagSrch ' go back in possible BB code string' ---End Loop to find ]
425 If posBBCodeTagSrch = 0 Then GoTo TheEnd ' For any outer search failed to find a ] at all or a search for matching start tag that was fruitless
430 FkOffCrd: Rem 3) "I think we come here with a complete set of 4 positions"
440 If BcrdEEnd <> 0 And BcrdESt <> 0 And BcrdSEnd <> 0 And BcrdSSt <> 0 Then 'Just to check'
450 Dim SttBcrd As String, StpBcrd As String ' Start and stop tags as coplete strings including [ and ]
460 Let SttBcrd = Mid(strRmveBBCode, BcrdSSt, BcrdSEnd - BcrdSSt + 1) ' ' like |Color=Red|
465 Let StpBcrd = Mid(strRmveBBCode, BcrdESt, BcrdEEnd - BcrdESt + 1) ' ' like |/Color|
470 Dim SttWrd As String, StpWrd As String
480 Let StpWrd = Mid(StpBcrd, 3, Len(StpBcrd) - 3) ' like Color from |/Color| - Whole Word, from 3rd Chr , for Length as WholeWord-3
490 Let SttWrd = Mid(SttBcrd, 2, Len(StpWrd)) ' like Color from |Color=Red|
500 If UCase(SttWrd) = UCase(StpWrd) And Mid(StpBcrd, 2, 1) = "/" Then 'Ucase allows for differences in cases And Mid(SttBcrd, Len(SttWrd) + 2, 1) = "=" Then
510 Let strRmveBBCode = Replace(strRmveBBCode, SttBcrd, "", 1, 1) ' Replace in ( strRmveBBCode , the start tag , with no string , start loooking from and return from character 1 )
515 Let strRmveBBCode = Replace(strRmveBBCode, StpBcrd, "", 1, 1)
520 Else 'No shortening of string for non matching tag word
530 End If
540 Else 'No shortening of string for not all 4 [ and ] found. Not sure if I ever come here..
550 End If
560 Else ' no last ] of a possible Code section yet, so keep going back down in the main string , main loop
570 End If
580 Next posCurrent '_-===Main Loop========================================================================================
590 TheEnd:
600 MsgBox Prompt:="" & strRmveBBCode & "": Debug.Print "" & strRmveBBCode & "" 'Hit Ctrl+g when in VB Editor Window, reveal Immediate window after code run
End Sub
-
Wild Things. You make my heart sing. They make everything..... Groovy
The VBA code in the last few posts is a bit of a long way around of doing what can be done in a Word Dialogue box type thing using Wild things:
http://www.gmayor.com/replace_using_wildcards.htm
http://imgur.com/4Nqj1HP
The problem is getting at the Wild Things needed in the Wild Find String.
I can’t do it. But Hans and Paul did it for me here:
http://www.eileenslounge.com/viewtop...=26030#p202107
Here is my attempt at an ‘ExPlanation of the solution:
Wild Things. You make my heart sing. They make everything….. Groovy
Wild Things. You make my heart sing. They make everything….. Groovy
http://listenonrepeat.com/watch/?v=H...s_-_Wild_Thing
Wild things…. I think I hate you .. But I wanna know for sure… so
A Summary :)
As example. We want to remove the start and stop tags in a sample string containing a start and stop tag such as this_..
[color=Green]This is green[/color] This ‘aint matey
_.. What we finally want is this:
This is green This ‘aint matey
We use a combination of Wild things , or like a pattern to search for [ Find ] any bits like _..
[color=Green]This is green[/color]
_.. and [ Replace ] that “Find”ed with
This is green
We can do, it Wildly, man, as follows:
As always the search is done from left to right
The way I do it below is probably not the most efficient way, in fact it is probably pretty stupid, but is just to demo the idea
Optional use of ( ) in the Wild thing search string
We can use brackets ( ) , optionally , to identify, ( for later use ) , the exact string parts found by the constituent Wild things in the ( ) in which they are in:
So in this example we will use a ( ) for
_ the Wild things that find the color so that the actual word color can be used again in the same wild stuff string, so as to make sure that we find in the end tag the matching word to that in the start tag.
_ Also we need a ( ) to identify the wild things that Find This is green , as we want to use that in , or rather for the complete, Replace string.
A bracket is identified by , for example, \2 if I want to reference the actual string found by the wild things we enclose in the second ( )
Build up final Wild thing Replace string, left to right, by breaking string we want up into bits. Each bit will be found by a Wild thing or things
So we are looking to break the to search for Wild [ Find ] Thing string down thus:
Code:
[ & ( AnythingWithout=or] ) & anything & ] & (Anything) & [\ & \1 & ]
So I am breaking it down in to 8 bits. So I need 8 sections of wild stuff to Find those.
\1 is at the 7th position and refers to what is actually found by the search for ( AnythingWithout=or] ) at position 2 ( which is bracket ( ) number 1 )
Excel starts at the left. What no literature really states clearly ( and is only obvious once you know it ) is this:
_ For most sections, Excel keeps going to the right until it Finds what the Wild thing tells it to. That is then stored, but only if that found string also has joined to it the string type in the next section’s Wild thing. Those two sections are then stored ( as well as storing separately if either of those two sections are enclosed in ( ) ), but only if that found string also has joined to it the string type in the next section’s Wild thing. That is then stored, but only if that found string also has joined to it the string type in the next section’s Wild thing. ……..etc.
A common Wild thing is * . This means anything characters and any amount. This will only include, however, anything up to if and when the next Wild thing is satisfied.
The 7th Wild thing I already have which is \1 which is referring to the 1st bit enclosed in a ( ) , which is the second bit in the broken up string , ( which is anything without a = or a ] . In our example this will be color) . Note: The number refers to the number from the left of any ( ) that I may have included, not the actual sections.
Just to make that last point clear, and to demonstrate another, I will do this_..
Code:
[ & ( AnthingWithout=or] ) & ( Anything & ] ) & (Anything) & [/ & \1 & ]
_.. so my Replace is then \3 . I do not need the second ( ___ ) , which I could reference by \2, ( and it can help to result in an “expression too complex” error ! ).
I put the second ( ___ ) in also to demo that a ( __ ) can include more than one wild bit
So here is one example Find sting with Wild things that “works” ( I added spaces to show better the 8 sections, but in use those spaces must be removed ). There are three optional ( ) sections. The second ( ) section encloses two Wild thing sections: Those are the third and forth counting from the left.
Code:
[\[] ([!\]=]@) (* \]) (*) \[/ (\1) \]
This is the actual Wild Find string
___ [\[]([!=\]]@)(*\])(*)\[/(\1)\]
To '_- ExPlain the 8 parts:
Part 1 [\[]
Excel start “looking” from the left to find a [
As a general rule Wild things are enclosed in a [ ] pair to identify them as such. So a [ ] is a Wild thing. They do not always have to be enclosed in a [ ], as is the case here. Here we are effectively looking to Find a single simple character, [.
( In the final Find string, only the second Wild section needs to be enclosed partly in a [ ] pair ).
So this section written as \[ instead is just as good. I suspect my use of the extra [ ] here does not have any bad effects, as it might be that the final string would be at compile or whatever reduced to \[ in either use of \[ or [\[]
We need to use the Wild thing, \ , quite a bit , in our total string for the same reason that we do here: This is because the \ has another use in Wild things in addition to the already discussed way like \7 ( where 7 would be for the 7th ( ) ). This other use of \ is to allow us to use characters as simple text which have a specific use in Wild things, so that Excel knows that we want to use them as their literal text string, rather than as Wild thing. Here it is needed for the first [ which we want to find.
( It follows that if we were looking for a \, then we would need to use \\ )
In our example string we find with this first Wild thing section the first [
Part 2 ([!\]=]@)
As noted the ( ) allows the string actually found in this Wild bit to be used later to the right via the reference \1.
As for this:
[!\]=]@ ( which could just as well be written [!=\]]@ )
We need a [ ] pair here, as within that is part of the Wild instructions for what to search for , and that has a further Wild instruction, @ , applied to that.
So in such a [ ] pair we would normally expect some specific wild stuff
Here the Wild thing, ! , means we search for any character other than those after included up to the closing tag ]. In our sample string , our first Wild bit found the first [ which now has added on any string at the next character if it is not a = or a ]
So this part of the second wild bit will find c in our sample string. If we had no other wild instructions here, then Excel would be content/ satisfied with that c. That would be joined on to the first [ found, so our result so far would be [c . In effect Excel stops going to the right when it is satisfied, and goes on to the next Wild bit. But we have another wild instruction here: The @ instructs to look for any amount of characters meeting the conditions before it, in this case the conditions in the [ ]. So the “Find” will stop finding characters when it no longer has a not = or a not ]. In our sample string the characters meeting the conditions are tacked on to a [ so will be will be [color. What [!\]=]@ has actually found and what the brackets ([!\]=]@) can be thought of as “holding” is color.
An alternative for @ would be {1,} which looks for between 1 and any amount of what is before it.
If we had used {1,4} or {2,4} instead of @ we would have so far for the complete found string [colo
If we had used {5,5} we would not have found a matching code tag word with less than 5 characters.
Parts 3 and 4 (*\])
This is unnecessarily in ( ) . *\] will do
The literature says * looks for any amount of anything. I think that is not strictly correct, or at least, explains it badly. It would appear to look for any amount of anything only until the next wild condition is met. That is why I chose to put it in ( ) just to demo the dependence, as it were. But this (*)(\]) or this *\] would work just as well (*)(\]).
Once again the \ is required for telling Excel that we want it to recognise ] as a string rather than a specific Wild thing. For this section , with my example string, I get from this complete 2 part Wild section
=green]
If our code tags were of the form like: [b]SomeBoldText[/b] , then the search would have “stopped before it started”, as it were, as the ] would have “stopped” it
The combination of the 2 part Wild sections in this case would return just the single text character ]
Parts 5 and 6 (*)\[/
I contradict what I said in the last section slightly by using a ( ) around the * . Once again the * does nothing useful without the next wild bit to “stop” it. But what it does Find before it “stops” is what we actually need for Replace string. Hence I need a ( ) to reference what it Finds. This total Part 5 and part 6 section returns in our example
This is green[/
and the part referenced inside the ( ) is
This is green
Part 7 (\1)
As discussed already here the Wild thing, \1 , instructs to Find a string equal to that actual text found in the first ( ) if it is just before the next to be found ( which we will see in the next Part is the last character pair found, [/ ). The actual string found by [!\]=]@ in Part 2 , was , in our example the text color
Part 8 \]
Finally only a complete final Find attempt is successful if the last character is a ] , that is to say if the character after the text, in our example, the second color, is a ]
_...
The Final “Find”ed String for our example would be
[ & color & =Green & ] & This is green & [/ & color & ]
-
Here is a simple code to use the Find and Replace discussed in the last Post
The code should go in a code module in a WORD .docm File
Before rung the code, a text which includes BBCode Code Tags , should be selected in a Word document.
The Code makes a temporary File, "TempBBCodeCopy1.docx", holding the original selected text, then removes the BB Code Code Tags from the text and saves that as another temporary File, "TempNoBBCodeCopy2.docx"
Code:
Sub WegDaMitHansPaulAlan() ' http://www.eileenslounge.com/viewtopic.php?f=26&t=26030#p202223
Rem Code Part 1) make two temporary Word Files with and without BB Code
Rem 1) Copy selection to Clipboard
Selection.Copy
Rem 2) Make temporary WORD document
Documents.Add: ActiveDocument.Content.Paste
' 2b) Copy of Full Text with BB Code
Dim FullFilePathAndFullNameBBCode As String
ActiveDocument.SaveAs Filename:="TempBBCodeCopy1.docx", FileFormat:=wdFormatXMLDocument
Let FullFilePathAndFullNameBBCode = ActiveDocument.Path & "\" & ActiveDocument.Name
Rem 3) Replace Code tag pairs with what is in between
Selection.WholeStory
With Selection.Find
.ClearFormatting: .Replacement.ClearFormatting
.Wrap = wdFindStop
.MatchWildcards = True '
.Text = "[\[]([!=\]]@)(*\])(*)\[/(\1)\]" ' 8 sections, 4 identified with ( ) but I only need two ( )
.Replacement.Text = "\3" ' The third of the 4 sections identified with a ( )
.Execute Replace:=wdReplaceAll
End With
' 3b) Copy of Colored Text without BB Code Code tags
Dim FullFilePathAndFullNameNoBBCode As String
ActiveDocument.SaveAs Filename:="TempNoBBCodeCopy2.docx", FileFormat:=wdFormatXMLDocument
Let FullFilePathAndFullNameNoBBCode = ActiveDocument.Path & "\" & ActiveDocument.Name
Rem 4) "Reset the "Find Replace Text Dialogue" "Thing" "
ActiveDocument.Select
Selection.WholeStory
With Selection.Find
.ClearFormatting: .Replacement.ClearFormatting: .Text = "": .Replacement.Text = "": .Forward = True: .Wrap = wdFindAsk: .Format = False: .MatchCase = False: .MatchWholeWord = False: .MatchKashida = False: .MatchDiacritics = False: .MatchAlefHamza = False: .MatchControl = False: .MatchWildcards = False: .MatchSoundsLike = False: .MatchAllWordForms = False '
End With
Rem 5) Option to close / kill document
ActiveDocument.Close (wdDoNotSaveChanges)
'Kill FullFilePathAndFullNameBBCode
'Kill FullFilePathAndFullNameNoBBCode
End Sub ' End Code Part 1)
-
Full Code "Belt and Braces” in Word Find Replace & String Manipulation of initial Text String in Clipboar
Full Code "Belt and Braces" in Word Find Replace & String Manipulation of initial Text String in Clipboard
This code is simply doing the two ways to remove BB Code code tag pairs from a copied to the clipboard Text from a Word document.
A check is then done Finally to see if the two raped from tags strings are the same.
I would not be surprised if a fail in the strings match just means that the second method, ( my long string manipulation way ) is getting it wrong.. Lol.. but never mind :) ***
***Edit: - like I just did: It will not work for nested BBCode code tags like
[CENTER][B]Issue Forum for Issues suggestions for improvement Forum for Issues obfuscation[/B][/CENTER]
This is OK
[B]Issue Forum for Issues suggestions for improvement Forum for Issues obfuscation[/B]
:rolleyes:
That will do for this one, I guess I will have to do a recursion wonk to get a version working with nested BB Code Tag code tags,
_.____________-
:rolleyes:
Ok. Here we go:
This code _..
Sub BBCodeCodeTagsWegDaMit2AlanHansPaul2()
_.. is mostly just splicing together codes
Sub WegDaMitHansPaulAlan()
and
Sub LongWayOfDoingIt()
along with adding a short section, Rem 10a) to check that the strings are the same. That is to say the
Full Story selection text from the modified ( removed BB Code code tags ), NewWordText for Code Part 1)
is
compared with the final RapedText from the long string manipulation Code part 2)
The code is all one code and broken down into this and the next three posts
Code part 1 of 4 parts ( all following parts to be copied directly under the preceding part in the same code module.
Code:
Sub BBCodeCodeTagsWegDaMit2AlanHansPaul2() ' http://www.excelforum.com/development-testing-forum/1086445-forum-tools-test-no-reply-needed-4.html#post4586680
' === Code assumes you have a Word File open, and have selected some Text
' One way is automating doing it in Word. "Wild Things. You make my heart sing. They make everything….. Groovy" '_- http://www.eileenslounge.com/viewtopic.php?f=26&t=26030#p202322
Rem 0) ' Just mucking about a bit with refering to Word documents
' Documents.Item("eileenslounge.docm").Activate
'Dim DocNme As String ' ' Prepares "Pointer" to a "Blue Print" (or Form, Questionaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular "Value", or ("Values" for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. A String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quich checks.. But..http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring-2.html#post44116
' Let DocNme = ActiveDocument.Name ' ' '_-So A variable in VBA is like the Link to the part of a URL string reducing size site where a few things about the actual Final site is informed about. This area in that site, like a pigion Hole to which the variable refers, ( the "pigeon hole" location address, and all its contents would be defined as the "Pointer". Amongst other things it has a link, a "Pointing part", pointing to actually where all the stuff is
Dim Doc As Document 'A variable in VBA is like the Link to the part of a URL string reducing size site where a few things about the actual Final site is informed about. This area in that site, like a pigion Hole to which the variable refers, ( the "pigeon hole" location address, and all its contents would be defined as the "Pointer". Amongst other things it has a link, a "Pointing part", pointing to actually where all the stuff is
Set Doc = ActiveDocument 'EP Set: Fill or partially Fill: Setting to a Class will involve the use of an extra New at this code line. I will then have an Object referred to as an instance of a Class. At this point I include information on my Pointer Pigeon hole for a distinct distinguishable usage of an Object of the Class. For the case of something such as a Workbook this instancing has already been done, and in addition some values are filled in specific memory locations which are also held as part of the information in the Pigeon Hole Pointer. We will have a different Pointer for each instance. In most excel versions we already have a few instances of Worksheets. Such instances Objects can be further used., - For this a Dim to the class will be necessary, but the New must be omitted at Set. I can assign as many variables that I wish to the same existing instance
Rem Code Part 1) make two temporary Word Files with and without BB Code
-
Code part 2 of 4 parts
Code:
Rem Code Part 1) make two temporary Word Files with and withouut BB Code
Rem 1) Copy selection to Clipboard
Selection.Copy
Rem 2) Make temporary WORD document 'Bit of a bodge to get the text in a selection: create a Word file and paste to it
Dim NextTempDoc As Document '
Documents.Add: ActiveDocument.Content.Paste 'Make a File Copy in current Application based on Default Type : And Paste from Clipoard ( ...!!!...our original selected text ) using the Default Copy which should at least have all the text, which is all we are interested in here.
Set NextTempDoc = ActiveDocument ' Do this in case i muck about- I do not want to inadvertently close or kill the wrong document
'2b) Copy of Full Text with BB Code
Dim FullFilePathAndFullNameBBCode As String ' 'Prepares "Pointer" to a "Blue Print" (or Form, Questionnaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular “Value”, or (“Values” for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quick checks.. But...http://www.mrexcel.com/forum/excel-q...html#post44116
NextTempDoc.SaveAs FileName:="TempBBCodeCopy1.docx", FileFormat:=wdFormatXMLDocument 'Without this the document will not really "exist jet". It has a tempory name ( Used in Windows referrence ), but no path.
Let FullFilePathAndFullNameBBCode = NextTempDoc.Path & "\" & ActiveDocument.Name
Rem 3) From Han's Text Find Replacement Dialogue 'http://www.eileenslounge.com/viewtopic.php?f=26&t=22603#p175712
'3a) Take out all BB Code
Selection.WholeStory 'Selects whole document which here is just our selection of interest from the original document
Dim StrOrg As String: Let StrOrg = Selection.Text '11a)6b)' Original Text to use in string manipultion code of Code Part 2)
With Selection.Find 'This is the VBA code ( or very similar ) used by Excel when Using the Find eplace text Dialogue box. So this is an improved version of what a macro recording would give.
.ClearFormatting: .Replacement.ClearFormatting ' Don't use formating, ? not sure this comes into the equation ??
.Wrap = wdFindStop ' Tell Word not to continue past the end of the selection ( And therefore prevents also a display Alert asking )
.MatchWildcards = True
.Text = "[\[]([!=\]]@)(*\])(*)\[/(\1)\]" ' 8 sections, 4 identified with ( ) but I only need two ( )
.Replacement.Text = "\3" ' The third of the 4 sections identified with a ( )
.Execute Replace:=wdReplaceAll ' Replace all within selection. This is the "OK" button!
End With
Selection.WholeStory: Dim NewWordText As String: Let NewWordText = Selection.Text '´11a) New text for comparison with result from Code Part 2)
'3b) Copy of Colored Text in Word File without BB Code Code tags
Dim FullFilePathAndFullNameNoBBCode As String
NextTempDoc.SaveAs FileName:="TempNoBBCodeCopy2.docx", FileFormat:=wdFormatXMLDocument 'Without this the document will not really "exist jet". It has a tempory name ( Used in Windows referrence ), but no path.
Let FullFilePathAndFullNameNoBBCode = NextTempDoc.Path & "\" & ActiveDocument.Name
Rem 4) "Reset the "Find Replace Text Dialogue" "Thing" ". if you do not there may be some changed setting there that could catch you out next time you use it.
NextTempDoc.Select ' Re select the...( actually this line alone seems to do it )
Selection.WholeStory '...whole document
With Selection.Find
.ClearFormatting: .Replacement.ClearFormatting: .Text = "": .Replacement.Text = "": .Forward = True: .Wrap = wdFindAsk: .Format = False: .MatchCase = False: .MatchWholeWord = False: .MatchKashida = False: .MatchDiacritics = False: .MatchAlefHamza = False: .MatchControl = False: .MatchWildcards = False: .MatchSoundsLike = False: .MatchAllWordForms = False '
End With
Rem 5) Optiion to close / kill document
NextTempDoc.Close (wdDoNotSaveChanges) ' Giving the option will also prevent being asked for it. You must close. VBA will not let you kill an open sheet, as you are affectively working on a copy, and VBA is assumng the Original can be got at by saving for example. http://www.mrexcel.com/forum/excel-questions/920451-excel-macro-files.html#post4425428
'Kill FullFilePathAndFullNameBBCode ' Use the Kill wisely!!!! - where this goes there 'aint no coming back!!
'Kill FullFilePathAndFullNameNoBBCode
Rem Code Part 2 Put text without BB code into clipboard
Rem 6) Use data Object ( assumes we copied to the Clipboard )
'1 a) Data Object to get the data from the clipboard.
'_- ExPlanation Dim :'_-: For Object variabls: Address location to a "pointer". That has all the actual memory locations (addresses) of the various property values , and it holds all the instructions what / how to change them , should that be wanted later. That helped explain what occurs when passing an Object to a Call ed Fucntion or Sub Routine By Val ue. In such an occurance, VBA actually passes a copy of the pointer. So that has the effect of when you change things like properties on the local variable , then the changes are reflected in changes in the original object. (The copy pointer instructs how to change those values, at the actual address held in that pointer). That would normally be the sort of thing you would expect from passing by Ref erence. But as that copy pointer "dies" after the called routine ends, then any changes to the Addresses of the Object Properties in the local variable will not be reflected in the original pointer. So you cannot actually change the pointer.)
'_- Explanation Set :'_-: Fill or partially Fill: Setting to a Class will involve the use of an extra New at this code line. I will then have an Object referred to as an instance of a Class. At this point I include information on my Pointer Pigeon hole for a distinct distinguishable usage of an Object of the Class. For the case of something such as a Workbook this instancing has already been done, and in addition some values are filled in specific memory locations which are also held as part of the information in the Pigeon Hole Pointer. We will have a different Pointer for each instance. In most excel versions we already have a few instances of Worksheets. Such instances Objects can be further used., - For this a Dim to the class will be necessary, but the New must be omitted at Set. I can assign as many variables that I wish to the same existing instance
'Dim objCliTextCopied As DataObject '**Early Binding. This is for an Object from the class MS Forms. This will be a Data Object of what we "send" to the Clipboard. So I name it CLIpboardSend. But it is a DataObject. It has the Methods I need to send text to the Clipboard
' Set objCliTextCopied = New DataObject '**Must enable Forms Library: In VB Editor do this: Tools -- References - scroll down to Microsoft Forms 2.0 Object Library -- put checkmark in. Note if you cannot find it try OR IF NOT THERE..you can add that manually: VBA Editor -- Tools -- References -- Browse -- and find FM20.DLL file under C:\WINDOWS\system32 and select it --> Open --> OK. http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
' ( or instead of those two lines Dim obj As New DataObject ). or next two lines are.....Late Binding equivalent'
Dim objCliTextCopied As Object ' Late Binding equivalent' If you declare a variable as Object, you are late binding it. http://excelmatters.com/2013/09/23/vba-references-and-early-binding-vs-late-binding/
Set objCliTextCopied = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") ' http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
'6a) Original text string from '11a) The line below means I have nothing to do with the Clipboard yet' - see furhter to the right for .Geting From Clipboard for if it had been in it ' 'Put all? Clipboard Infomation into Data Object
objCliTextCopied.SetText Text:=StrOrg ' I am messing about putting this in data object, then taking it out on 6b) , but I just wanted the code to be more flexible for later use. ' ''objCliTextCopied.GetFromClipboard 'All that is in the Clipboard goes in this Data Object initial instance of the Class This line does not seem to be necerssary for the next Geting Text bit
-
Code Part 3 of 4 parts
Code:
'6b) get code as long string String. This can be very long
Dim TextWithBBCodeEnit As String ' 'Prepares "Pointer" to a "Blue Print" (or Form, Questionnaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular “Value”, or (“Values” for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quick checks.. But...http://www.mrexcel.com/forum/excel-q...html#post44116
Let TextWithBBCodeEnit = objCliTextCopied.GetText() ''retrieve the text in this instance of the Class. ( Our code as a String with probably BB Code Code tags, vbCr vbLf etc.
Rem 7) Determine length of original text
Dim LenText As Long ' ' Long is very simple to handle, - final memory "size" type is known (123.456 and 000.001 have same "size" computer memory ) , and so a Address suggestion can be given for the next line when the variable is filled in. '( Long is a Big whole Number limit (-2,147,483,648 to 2,147,483,647) If you need some sort of validation the value should only be within the range of a Byte/Integer otherwise there's no point using anything but Long.--upon/after 32-bit, Integers (Short) need converted internally anyways, so a Long is actually faster. )
Let LenText = Len(TextWithBBCodeEnit)
MsgBox prompt:="Text with BB Code Character count is " & LenText
Rem 8) Take out BB Code bits from text string.
40 Dim strRmveBBCode As String: Let strRmveBBCode = TextWithBBCodeEnit ' = strBBCode ' This will be adjusted until finally has no BBCode tag pairs
50 Dim Lstr As Long ' This will be adjusted as necerssary for current length ' Long is very simple to handle, - final memory "size" type is known (123.456 and 000.001 have same "size" computer memory ) , and so a Address suggestion can be given for the next line when the variable is filled in. '( Long is a Big whole Number limit (-2,147,483,648 to 2,147,483,647) If you need some sort of validation the value should only be within the range of a Byte/Integer otherwise there's no point using anything but Long.--upon/after 32-bit, Integers (Short) need converted internally anyways, so a Long is actually faster. )
60 Let Lstr = Len(TextWithBBCodeEnit) ' Len(strBBCode)
70 Rem 2) Loop through and get a BB Code section
80 Dim strBBCodePair As String ' for a found valid pair '
' Prepares "Pointer" to a "Blue Print" (or Form, Questionaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular “Value”, or (“Values” for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. A String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quich checks.. But..http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring-2.html#post44116
90 Dim posCurrent As Long 'Current position in the string' Loop Bound variable Count '_-Main Loop==========================
100 For posCurrent = Lstr To 2 Step -1 'Important to go backwards as we chop off behind us so have a less complicated current position. We look at pos-1 in some code parts so we would error if we went back to less than 2
110 '2a) Check for a ]
120 If Mid(strRmveBBCode, posCurrent, 1) = "]" Then
130 Dim posBBCodeTagSrch As Long 'For search through possible valid BBCode Section'_-Loop for Pos tag pair section--
140 Dim BcrdEEnd As Long: Let BcrdEEnd = posCurrent 'Position of possible End Code Tag End
150 For posBBCodeTagSrch = posCurrent - 1 To 2 Step -1 'PosCurrent is set here at loop start. ###It is not effected by cardinally sining changing PosCurrent Loop Bound variable caount in Outer main Loop
160 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "]" Then GoTo NxtCESPosPos ' If we hit another ] then start again to see if is a valid BB code section
170 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "/" And Mid(strRmveBBCode, posBBCodeTagSrch - 1, 1) = "[" Then 'We hit start of a BB Code end tag
180 Dim BcrdESt As Long: Let BcrdESt = posBBCodeTagSrch - 1 'Position of End Code Tag Start
190 Exit For ' We leave this For the End Code Tag Start Search, Exit For with a [ at posBBCodeTagSrch-1
200 Else 'Not found start of end Tag or stop of end Tag.
210 End If
220 NxtCESPosPos: Next posBBCodeTagSrch ' go back in possible BB code string
230 If posBBCodeTagSrch = 3 Then Exit Sub 'case we never found the start of an End Code Tag
240 For posBBCodeTagSrch = posBBCodeTagSrch - 2 To 2 Step -1 ' Once again ### the start is set and fixed, the Loop Bound Variable Count will change
250 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "]" Then
260 If Mid(strRmveBBCode, posBBCodeTagSrch - 1, 1) = "]" Then GoTo NxtCSSPosPos ' If we hit another ] then start again to see if is a valid BB code start section
270 Dim BcrdSEnd As Long: Let BcrdSEnd = posBBCodeTagSrch 'Position of possible Start Code Tag End
280 Dim LTagStLoop As Long 'Last loop to find start of start Code Tag
290 For LTagStLoop = posBBCodeTagSrch - 1 To 1 Step -1 '_- Second inner loop___________________________
300 If Mid(strRmveBBCode, LTagStLoop, 1) = "[" Then
310 Dim BcrdSSt As Long 'Have to put it here, - I may occaisionally have to set it to 0 in next line
320 If Mid(strRmveBBCode, LTagStLoop + 1, 1) = "/" Then Let BcrdEEnd = BcrdSEnd: Let BcrdSEnd = 0: Let BcrdESt = LTagStLoop: Let BcrdSSt = 0: Let posBBCodeTagSrch = LTagStLoop: GoTo NxtCSSPosPos ' Found a second end Code Tag. So change the previous found start and stop , and adjust the Loop Bound variable Count appropriately for a new search for a start Code Tag
330 Let BcrdSSt = LTagStLoop
340 Let posCurrent = BcrdSSt 'End of Code Tag section search
350 GoTo FkOffCrd ' We leave this For the start Code Tag Start Search and go to Fuk Off Crd:
360 Else ' Still looking for start of start Code Tag
370 End If
380 Next LTagStLoop '_- Second inner loop________________________________________________________________
390 If LTagStLoop = 1 Then GoTo TheEnd 'Case we found a start start [ at 1 or failed to find a start start [ for the complete possible Code Tag section search
400 Else 'Not found end of start Tag or start of start Tag
410 End If
420 NxtCSSPosPos: Next posBBCodeTagSrch ' go back in possible BB code string'_-Loop for Pos tag pair section-----------------
-
Code part 4 of 4 parts
Code:
430 FkOffCrd: Rem 3) "I think we come here with a complete set of 4 positions"
440 If BcrdEEnd <> 0 And BcrdESt <> 0 And BcrdSEnd <> 0 And BcrdSSt <> 0 Then 'Just to check'
450 Dim SttBcrd As String, StpBcrd As String ' Start and stop tags
460 Let SttBcrd = Mid(strRmveBBCode, BcrdSSt, BcrdSEnd - BcrdSSt + 1): Let StpBcrd = Mid(strRmveBBCode, BcrdESt, BcrdEEnd - BcrdESt + 1)
470 Dim SttWrd As String, StpWrd As String ' like |Color=Red|, |/Color|
480 Let StpWrd = Mid(StpBcrd, 3, Len(StpBcrd) - 3) ' like Color from |/Color| - Whole Word, from 3rd Chr , for Length as WholeWord-3
490 Let SttWrd = Mid(SttBcrd, 2, Len(StpWrd)) ' like Color from |Color=Red|
500 If UCase(SttWrd) = UCase(StpWrd) And Mid(StpBcrd, 2, 1) = "/" Then 'Ucase allows for differences in cases And Mid(SttBcrd, Len(SttWrd) + 2, 1) = "=" Then
510 Let strRmveBBCode = Replace(strRmveBBCode, SttBcrd, "", 1, 1) ' Replace in ( strRmveBBCode , the start tag , with no string , start loooking from and return from character 1 )
515 Let strRmveBBCode = Replace(strRmveBBCode, StpBcrd, "", 1, 1)
520 Else 'No shortening of string foe invalid tag word
530 End If
540 Else ' no last ] of a possible Code section yet, so keep going back down in the main string
550 End If
560 Else
570 End If
580 Next posCurrent '_-===Main Loop========================================================================================
'590 TheEnd:
600 MsgBox prompt:="" & strRmveBBCode & "": Debug.Print "" & strRmveBBCode & "" 'Hit Ctrl+g when in VB Editor Window, reveal Immediate window after code run
Dim RapedText As String: Let RapedText = strRmveBBCode ' TextWithBBCodeEnit with BB Code Code tags removed
Rem 9) This a Another Object from class to be sure we have the data in the Clipboard
'Dim objDat As DataObject
'Set objDat = New DataObject 'Set to a new Instance ( Blue Print ) of dataobject
Dim objDat As Object
Set objDat = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
'9b) Put in (and Get back from clipboard) the raped text.
objDat.SetText Text:=RapedText 'Make Data object's text equal to original text without the BB Code Code Tags
objDat.PutInClipboard 'Place current Data object into the Clipboard
objDat.GetFromClipboard 'All that is in the Clipboard goes in this Data Object second instance of the Class.
Dim TxtOut As String: Let TxtOut = objDat.GetText() 'retrieve the text in this second instance of the Class. ( In this case all in it is the text and possibly vbCr and vbLf )
MsgBox prompt:="You dumped in Clipboard this " & vbCr & RapedText & vbCr & "and if you try to get it, you should get" & vbCr & TxtOut & ""
Rem 10a) Code Part 3) Belt and braces check. A check is then done finally to see if the two raped from tags strings are the same
If NewWordText <> RapedText Then MsgBox prompt:="Text from Word Dialogue Box Find Replace Wild card way, and " & vbCrLf & "Long String manipulation way are not the same. Oh dear"
'10b) Tidy up.
TheEnd: ' ( Come here always, even on a unpredictable error ) or i wouod If i had an error Handler, Lol.
Set objDat = Nothing ' Good practice... maybe....
Set objCliTextCopied = Nothing ' ....... http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring.html#post4414065
End Sub
-
Recursion Wonk. To remove BB Code tag pairs incuding nested ones missus
One problem noted in the previous codes was that the case of nested BB Code tag pairs, the codes did not work. At many forums such nesting of this form is permitted in BB codes.
[color=Green]Comments [color=Red]Highlight[/color] Comments[/color]
The returned result is
Comments Highlight Comments
None of the codes discussed so far will work for such a case.
Should the Code tag type be dissimilar, such as_..
[CENTER][B]Title[/B][/CENTER]
_..then at least the Find Replace Wildcard Code will work for that by virtue of matching in the String first, for example, in the above example, _..
__ CENTER __ __ __ __ CENTER __
_.. then
__ B __ __ __ __ B __
However my Long string manipulation code will not even work for that.
I have done a Long string manipulation code to be discussed in this and the following posts which , I think, work for all situations.
Brief Descriptions is:
The entire string is held in a variable, strBBCode. This is declared in a Subroutine. Something similar to that was done for the last code )
change 1) Minor to last code:
Unlike the previous codes, ( which sequentially removed BB Code code tags ( by replacing with "" )), the code tags are replaced by some arbitrary character ( This is simply chosen as any not likely to be used as text in the main initial string https://www.mrexcel.com/forum/excel-...ml#post4214083 )
change 2) Minor
This itself is not such a major change in the code format, but it facilitates the main change, 3) below. This change is that bulk of the code is within a Function, (Function LongWayOfDoingIt2ReCurseCyClops(__ ) . It is “Called” and needs to be given_..
_.. the string, strBBCode, By Referral to that variable, rather than its By its Value contents
and_..
_.. a Value for the current character position, which initially will be the end ( or length in characters ) position of strBBCode.
But those are not the main changed characteristic to the code.
To recap: All my long string manipulation codes, including this Function, have the general characteristic that they loop backwards in the complete string until a ] is found. An attempt is made then to find a [/ . Once this is found an attempt is made to find a ] and then a [ .
At this point a possible code pair requirement , looking backwards, of ] [/ ] [ is achieved
( Reversing that to the correct order shows that clearly more clearly,
[ _ ] __ [/ _ ],
or
[codeText] AnyText [/CodeText] .
Or
[Color=red] AnyText [/color]
_.. etc...)
Having found a code tag pair, a check is made for its validity ( the same matching work, such as, codetext, color, for example ) , before the adjustments are made to the main string. After that , the code then moves on and steps further “back” in search of another pair_..
_.. But just before it does that check, all codes, including this new Function, at the last found [ , do a check to see if in fact the next character after the last found [ is a / , indicating that in fact the assumed start tag, [codeText], was in fact another end tag, [/Codetext_b]. Action is then taken should that be the case.
At this point the codes are very different. The action taken is different
In the previous code, it was assumed that in such an event, the first found “end tag” was a rouge text looking like an end tag , but invalid, and not matched to a start code tag. The first found “end tag” was then ignored, and another search made for a matching start tag to the second found end tag.
This results in an error situation for a valid nested BB Code tags situations.
The new code works therefore much differently.
Main change 3):
In the new code, this point is around lines
430 – 460, Rem If [/ Then Oh dear time for a wonk.
Recursion is the name given for the general technique which at this point is used. It is whereby within a routine an instruction is given to run the routine.
:rolleyes: ... In other words the Routine “Calls itself”.
So what is all that about? :
‘_- I will tell you, Matey boy:
Any Function or Sub routine we write, is just a set of instructions. Like a piece of paper which is a Print out of the typed code instructions. It tells VBA what to do when it is run or called. I does not really physically go along or through the code lines: We just find that easy to visualise, or “look at “ when “stepping” through to debug a code. The code is just a set of instructions that VBA understands.
So imagine you are VBA and you are given a set of instructions ( on a piece of paper ) to do a job, (for example you are given a written copy of the instructions to read and follow).
You start doing the instructions.
Now, say, before you are finished, you are given a set of identical instructions and are told to do that by the boss. What do you do, ( apart from swear at him ) ?
The logical progression is, ( and that is what VBA does ), it stops what it is doing, so like freezes the initial running through the instructions , and starts again with the new ( duplicate as it happens in the case of “recursion”) set of instructions.
Once finished it goes back and picks up the first job where you / it left off. Within reason, there is no limit to how often you can do that in VBA. If a code makes a Function or Sub routine keep “Calling” itself , then it “stacks” up in order in a “waiting list” the stopped set of instructions. As each set of instructions is completed, the last are continued at the point where they were interrupted and “frozen”. That point is code line 450
It follows, ( although may not be immediate obvious as the same names are used) that all variables used in each run of the Function within the function are unique to that run of the function so do not influence the values of the similarly named variables in the other Function runs. An exception here is our main full string, strBBCode. This is because we have deliberately chosen to carry it over By such a way as to indicate it should be Referenced to within each Function. So in this case, changes made in any Function run to strBBCode will be Reflected in the main ( unique ) variable, strBBCode, which is initially “held” / declared in the initial calling code.
So what is all that to do with the main change to this code version ??
‘_- I will tell you, Matey boy:
Initially the Function is called the first time by a small Sub routine which passes to the Function two things
_(i) the variable strBBCode. It is indicated via the use of ByRef in the Function signature ( first ) line, that specifically that variable is to be Referenced. ( You may effectively take a variable “into” the Function ( ByRef ) , or alternatively a Value. If an actual value is given, then giving it ByRef is just the same as By Value. If you pass a Variable ByValue the value at the time of the Call in the variable will be taken, and that variable will become local to the Function and so any changes to it made in the function will not be reflected in the variable “held” in the initial calling routine ........ )
_...(ii) a number .......Value... is given which will be the start position to work back from when looping backwards through the characters in strBBCode. For this first Call, that will be the length of / or character count of , strBBCode.
The Function code then transgresses as described and very similar to the previous code. It can go to completion in one run should no end code tag be encountered after an initial one is found and before a start tag is found.
____If a second end tag in sequence is found the "recursion wonk" kicks in.....
450 _____ Call LongWayOfDoingIt2ReCurseCyClops(strBBCode, BcrdSEnd)
So _ If this line is done, the current run freezes. A New Function begins. This is instructed to Refer to the unique main string strBBCode “held” in the original Calling routine. As Value for the current position in the backward stepping search is this time not the main string strBBCode length, but rather the position of the end ] in the currently found second sequential end code tag.
The only thing that is certain at this point is that the new Function run will immediately find this second end cote tag as its first end code tag. This is probably inefficient as it repeats some steps done. ( A more complicated Function could be envisaged to carry across an Offset to be applied to “jump” this search and pass the end code tag )
With no more nested code tag pairs, the second Function will complete the entire string, other than the possible code tag pair search “frozen” in the first Function.
When the first function resumes, the initial code tag pair search is completed.
There are many other scenarios including a further nested code tags section the second function finds and results in a third Function starting. That third Function would complete all but the two pairs searches “frozen” . At completion of the third Function, the second and then the first Functions with their respective code tag pair search would be completed.
Another scenario would be a double nesting such that there are three sequential end code tags. Once again a second followed by a third Function would be started. Once again, the third Function would complete all but the two pairs searches “frozen”. At completion of the third Function, the second and then the first Functions with their respective code tag pair search would be completed.
One can imaging many more scenarios
One common factor is that all but the final function will be searching through the replaced replacement characters. This probably makes the code a bit inefficient
Final usage of Function
Initial code to Call the Function for the first time. ( The function may Call itself one or more times further )
The Function will not run itself.
It needs to be Called with the initial parameters passed, the main string, strBBCode, along initially with the length of that string as the start point from which to step back.
A routine is needed for that.
Additionally, once the initial Function run , ( which is set off by this routine ) is finished, we will have the original string, strBBCode , returned in a modified form with the replacement character in place of all found code tags. These need to be removed, which can be easily achieved by replacing them with zero length strings.
An example code is given in the next post.
A few minor last thoughts..
This second solution for manipulating a long string text does not require stepping backwards. It was simply developed on from the last code. That code was easier to do backwards as in the code parts were deleted whilst stepping through the string: It was easier to deal with such a code in a backward loop, as things “behind me” are deleted. The problem with going forward is that “deleting in front of me” can require adjusting “where I am”, and the count to, or “final point of where I am going to”. – Think of it as you tripping up, or effecting where the end is, if you chop out the path in front of you: VBA can get messed up in Looping if you remove points in a progression that have not yet been considered.
Another way of thinking about that:
If I take bits out, then things shift back or down to fill the space. If I take things out in front of me, then by shifting back, things which I have not yet considered will change their position. This will likely mess up some order of progression.
If I go backwards, and delete things behind me, then any order changes will only affect things which I have already considered. My original progression plan and order of things not yet considered is still valid.
-
Final usage of Function
Initial code to Call the Function for the first time. ( The function may Call itself one or more times further )
The Function in the next Post will not run itself.
It needs to be Called with the initial arguments , ( __ ( strBBCode, BkStt) __ ), passed, the main string, strBBCode, along initially with the length of that string as the start point from which to step back, BkStt
A routine is needed for that.
Additionally, once the initial Function run , ( which is set off by this routine ) is finished, we will have the original string, strBBCode , returned in a modified form with the replacement character in place of all found code tags. These need to be removed, which can be easily achieved by replacing them with zero length strings.
Example Code:
Code:
'10 '
Sub TestsBBCodeString() '
20 '
30 Rem 2 Bits needed as Part of Solution
40 '2a) String will need to be got. The variable for it is referred to by changes in any Functions used. The initial length is effectively just the current position stepping back through the total character string
50 ' Some variables: So A variable in VBA is like the Link to the part of proxy site where a few things about the actual Final site is informed about. Tiny is the pointer. Amongst other things it has a link to actually where all the stuff is. Like Dim Str As String means at Str will be stuff like how long the text in that string is as well as a link to the memory where the whole string actually is. So that is like more efficient if you want to get at the length – you do not need to go off to where the ( possibly massive ) thing is.. etc.. :-)
60 Dim strBBCode As String ' ' Prepares "Pointer" to a "Blue Print" (or Form, Questionaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular “Value”, or (“Values” for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. A String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quich checks.. But..http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring-2.html#post44116
70 Let strBBCode = "gggg[d=fg]2[/d]45[/8]x[ddd[Cl=XYZ][/Cl]Any text" ' Any test string, this code part takes the place of a code section that might for example get the text that may hve been copied to the Clipboard
80 Dim Lenf As Long ' ' Long is very simple to handle, - final memory "size" type is known (123.456 and 000.001 have same "size" computer memory ) , and so a Address suggestion can be given for the next line when the variable is filled in. '( Long is a Big whole Number limit (-2,147,483,648 to 2,147,483,647) If you need some sort of validation the value should only be within the range of a Byte/Integer otherwise there's no point using anything but Long.--upon/after 32-bit, Integers (Short) need converted internally anyways, so a Long is actually faster. )
90 Let Lenf = Len(strBBCode)
100 '2b) Calling the Function (So a Sub would do also-as the Sub has arguments it would like any function not be shown in Macro list. The point of a ByRef call is to effectively return a value, a change to a value actually )
110 Call LongWayOfDoingIt2ReCurseCyClops(strBBCode, Lenf) ' This replaces the code tag characters to be removed with some arbritrary characters.
120 '2c) The arbritrary charachters need to be removed
130 Let strBBCode = Replace(strBBCode, "|", "", 1, -1) ' within strBBCode , "|" , replaced with "" , -1 indicating all of them
End Sub
The Function to be called_..
Public Function LongWayOfDoingIt2ReCurseCyClops(ByRef strBBCode As String, ByVal BkStt As Long) As String
_.. is given in the next post.
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
https://www.youtube.com/watch?v=f7xZivqLZxc&lc=Ugxq4JHRza_zx3sz0fx4AaABAg
https://www.youtube.com/watch?v=f7xZivqLZxc&lc=UgzMCQUIQgrbec400jl4AaABAg
https://www.youtube.com/watch?v=f7xZivqLZxc&lc=UgwhVTFaD469mW9wO194AaABAg. 9gJzxwFcnPU9gORqKw5tW_
https://www.youtube.com/watch?v=f7xZivqLZxc&lc=Ugyb8nmKKoXvcdM58gV4AaABAg
https://www.youtube.com/watch?v=f7xZivqLZxc&lc=UgwvvXcl1oa79xS7BAV4AaABAg
https://www.youtube.com/watch?v=f7xZivqLZxc&lc=UgxvIFArksPprylHXYZ4AaABAg
https://www.youtube.com/watch?v=f7xZivqLZxc&lc=Ugxq4JHRza_zx3sz0fx4AaABAg
https://www.youtube.com/watch?v=v_1iqtOnUMg&lc=UgxUbeYSvsBH2Gianox4AaABAg. 9VYH-07VTyW9gJV5fDAZNe
https://www.youtube.com/watch?v=v_1iqtOnUMg&lc=UgxLtKj969oiIu7zNb94AaABAg
https://www.youtube.com/watch?v=v_1iqtOnUMg&lc=UgyhQ73u0C3V4bEPhYB4AaABAg
https://www.youtube.com/watch?v=v_1iqtOnUMg&lc=UgzIElpI5OFExnUyrk14AaABAg. 9fsvd9zwZii9gMUka-NbIZ
https://www.youtube.com/watch?v=jdPeMPT98QU
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
-
Recursion Function to remove BB Code code tags, described in last two posts
Code:
'140 '
Public Function LongWayOfDoingIt2ReCurseCyClops(ByRef strBBCode As String, ByVal BkStt As Long) As String ' I do not actually need any As ______ as nothing is returned, but you never know a string to retuen might be useful later
150 Dim vTemp As Variant ' For Debugs
160 '
170 Rem 1) Main Loop for finding BB code pair String=====================================
180 Dim StpBk As Long
190 For StpBk = BkStt To 1 Step -1 ' Looking for the first ] likely at end of end tag.
200 Let vTemp = Mid(strBBCode, StpBk, 1)
210 If Mid(strBBCode, StpBk, 1) = "]" Then ' we note Position and need to look for a [/ On a recursion call this conditiuon is always met
220 Dim BcrdEEnd As Long: Let BcrdEEnd = StpBk ' Position of possible End Code Tag End
230 Dim posBBCodeTagSrch As Long ' For search through possible valid BBCode Section'_-Loop for Pos tag pair section--
240 For posBBCodeTagSrch = StpBk To 2 Step -1
250 If Mid(strBBCode, posBBCodeTagSrch, 1) = "]" Then Let BcrdEEnd = posBBCodeTagSrch: GoTo NxtCESPosPos ' If we hit another ] then change the stop tag stop character position and start again to see if is a valid BB code section
260 If Mid(strBBCode, posBBCodeTagSrch, 2) = "[/" Then ' Found a stop tag "[/" at posBBCodeTagSrch, so mark..
270 Dim BcrdESt As Long: Let BcrdESt = posBBCodeTagSrch ' ..Position of End Code Tag Start and ..
280 Exit For ' we have an end code tag from a possibly code tag pair section
290 Else 'No luck finding a "[/" start bit of stop tag yet so keep looking Matey
300 End If
310 NxtCESPosPos: Next posBBCodeTagSrch ' trying to find a start [/ pair further back keep looking Matey
320 If posBBCodeTagSrch = 3 Then Exit Function 'case we never found the start of an End Code Tag
330 ' Loop likely at end of start tag ]
340 For posBBCodeTagSrch = BcrdESt - 1 To 1 Step -1 ' Looping furhter back to find a "]" likely of a start code tag but possibly a nested stop tag
350 If Mid(strBBCode, posBBCodeTagSrch, 1) = "]" Then ' possible start from back of "]" likely of a start code tag but possibly a nested stop tag found so....
360 If Mid(strBBCode, posBBCodeTagSrch - 1, 1) = "]" Then GoTo NxtCSSPosPos ' we have a second "]" one back, looking back so this will be caught by next back 1
370 Dim BcrdSEnd As Long: Let BcrdSEnd = posBBCodeTagSrch ' Position of possible Start Code Tag End
380 Dim LTagStLoop As Long ' _- Most Innerloop to find start of start Code Tag
390 For LTagStLoop = posBBCodeTagSrch - 1 To 1 Step -1 ' _- Most inner loop [ likely start of start tag_
400 If Mid(strBBCode, LTagStLoop, 1) = "[" Then
410 Dim BcrdSSt: Let BcrdSSt = LTagStLoop
420 Rem If [/ Then Oh dear time for a "recursion wonk"
430 If Mid(strBBCode, LTagStLoop, 2) = "[/" Then 'Seems like our last attempt at finding a start tag caught a nested end tag
440 'Time to freeze this Function with current end tag info.
450 Call LongWayOfDoingIt2ReCurseCyClops(strBBCode, BcrdSEnd) ' Position of possible Start Code Tag End is actually another end tag end, so give this ] position as the start position and run another copy of the Function. At the start of which the first check should catch the ] and redo the finf´ding of the last tag complete so is a bit ineffecient
460 'Time to unfreeze this Function, and continue where left off having now possibly modified the main string for one or more nested tag pairs, as well as probably catching all but the possible pair that I froze on
470 Let posBBCodeTagSrch = LTagStLoop ' When we went off to the copy of the function our LTagStLoop was at the start of what turned out to be a nested end code tag. That is as good a place as any to strt going further back now to try to find the match for the end tag before the nested one. We will be going throught the lkast nested one, but never mind
480 GoTo NxtCSSPosPos ' unfreeze search for a matching start tag
490 Else ' As soon as we come here we are likely
500 End If ' ready to do the string modification for a found matching pair
510 Let StpBk = BcrdSSt ' - 1 will be done at Next StpBk 'End of Code Tag section search ' I am commiting the cardinal sin of changing the Loop bound variable caount in the main outer step back in character Loop
520 GoTo FkOffCrd ' We leave this For the start Code Tag Start Search and go to Fuk Off Crd:
530 Else
540 End If
550 Next LTagStLoop ' _- End Most inner loop [ likely start of start tag_
560 If LTagStLoop = 1 Then GoTo TheEnd 'I think here we must always be at LTagStLoop = 1 - Case I think we failed to find a start start [ for the complete possible Code Tag section search
570 Else ' Not found a "]" likely of a start code tag but possibly a nested stop tag found
580 End If
590 NxtCSSPosPos: Next posBBCodeTagSrch ' End Loop likely end of start tag ]
600 If posBBCodeTagSrch = 0 Then GoTo TheEnd ' For any outer search failed to find a ] at all or a search for matching start tag that was fruitless
610 FkOffCrd: Rem 3) "I think we come here with a complete set of 4 positions"
620 If BcrdEEnd <> 0 And BcrdESt <> 0 And BcrdSEnd <> 0 And BcrdSSt <> 0 Then 'Just to check'
630 Dim SttBcrd As String, StpBcrd As String ' Start and stop tags as complete strings including [ and ]
640 Dim LenSttBcrd As Long, LenStpBcrd As Long ' Some extra variables for clarity
650 Let LenSttBcrd = BcrdSEnd - BcrdSSt + 1: Let LenStpBcrd = BcrdEEnd - BcrdESt + 1 ' As taypical to get length of anything when start and stop positions are known.. -- (stoppos-startpos+1)
660 Let SttBcrd = Mid(strBBCode, BcrdSSt, LenSttBcrd) ' In String , part from [ , for length (stoppos-startpos+1) ' like |Color=Red| or |b|
670 Let StpBcrd = Mid(strBBCode, BcrdESt, LenStpBcrd) ' like |/Color| |/b|
680 Dim SttWrd As String, StpWrd As String
690 Let StpWrd = Mid(StpBcrd, 3, Len(StpBcrd) - 3) ' like Color from |/Color| - Whole Word, from 3rd Chr , for Length as WholeWord-3
700 Let SttWrd = Mid(SttBcrd, 2, Len(StpWrd)) ' like Color from |Color=Red|
710 If StrComp(StpWrd, SttWrd, vbTextCompare) = 0 And Mid(StpBcrd, 2, 1) = "/" Then ' If UCase(SttWrd) = UCase(StpWrd) And Mid(StpBcrd, 2, 1) = "/" Then 'Ucase allows for differences in cases
720 Mid(strBBCode, BcrdSSt, LenSttBcrd) = String(LenSttBcrd, "|") ' Mid can be used to put in strBBCode , starting from start of tag , for a length space within of the tag = any symbol as many times as that length space
730 Mid(strBBCode, BcrdESt, LenStpBcrd) = String(LenStpBcrd, "|")
740 Else ' ' No manipulationn of string for non matching tag word
750 End If
760 Else 'No manipulation of string for not all 4 [ and ] found. Not sure if I ever come here..
770 End If
780 Else ' Case no "]" found in main strBBCode
790 End If
800 Next StpBk ' Stepping further back in Main Loop for finding first "]"============
810 TheEnd:
820 ' Let LongWayOfDoingIt2ReCurseCyClops = "Return from Function after running" ' Option if I wanted to give a value to be returned from Function. By virtue of the ByRef at signature line I effectively continually apply changes to the variable strBBCode
End Function
-
2 Attachment(s)
BB Code Generating and Removing. Preparing Forum Post in Word
The next few posts are intended to share a few codes and ideas and explanations thereof for the some codes to manipulate text including BB Code Code Tags. The codes will consider text in a WORD document, or simple text copied from anywhere into the Clipboard.
One use of this would be that this prepared text could then be copied across to a Forum Editor before posting the Reply. This has been getting more popular recently.
Most people do not actually favor longer posts and prefer using the Forum Editor for a quick monochrome response. A minority have asked me to share the codes and stuff I use when preparing longer posts in Word. So will post here and refer here when I am asked. I don’t think it suits a “Tips and Tutorials “ post in this case
BB Code What is that.
You need to understand the basic idea about code of the HTM, HTML type . All you need to understand is the typical form , pseudo, like with a “start” and a “stop” so that the actual stored “source” file might look like this ( stored usually in plain black and white – I am just using color to help show up different bits )
_____|MakeColor=Red|I want this to be red|/MakeColor|
So that above would be stored in a simple text File with a name like “MyBBCodeText.txt”. It would just be monochrome ( Black and white) text.
In general , the purpose of such a code is to produce somehow in some way this, for you to “see”
_____I want this to be red
It is code of that basic sort that comes down the internet lines to you. Your Browser is like the program that translates that to what you want to see.
In Forum Software from a company or companies that go by the name of Bulletin or similar, they use a simplified version of this sort of code. The text of anything that you post is actually held in such a simple .txt type Text File.
If you wish to, you can actually write using the BB Code format in any reply window. What is then actually displayed in the final seen Thread, is what is interoperated by the Forum software: The Forum Software will recognize simple text and / or BB Code.
For example , If you type the following two BB Code lines in the Forum Editor Window:_..
( Note:For a “CODE tag pair” you have a short cut Icon # ( Not available at Eileen’s Lounge ) )_......
[color=red]I want this to be red[/color]
[CODE]This I want to come out in Code Tags[/CODE]
So it should look like this in the Forum Editor Window
CodeTags.jpg http://imgur.com/xmSkc4O Attachment 502044
Attachment 1896Attachment 1896
_....... then you will get this in the posted “seen” reply
CodeTagsPosted.jpg http://imgur.com/TeUUj02
Attachment 502046Attachment 1897
Attachment 1897
It is well worth logging in to the Forum, then going into the Test Area_..
http://www.excelforum.com/development-testing-forum/
http://www.eileenslounge.com/viewforum.php?f=4
_.., then start a Thread with a title such as “just testing - No reply needed”
Experiment with BB Codes, especially the BB code CODE Tags. You should always use code tags for code: See rule 3.
English: http://www.excelforum.com/forum-rule...rum-rules.html
Other languages: http://www.excelforum.com/forums-rules/
Here some of the available BB Codes:
http://services.runescape.com/m=foru...9,877,64690220
http://www.excelforum.com/misc.php?do=bbcode
For Eileen's Lounge there are some differing characterisics.
http://www.eileenslounge.com/viewtopic.php?f=50&t=108
Note the Forum editor “Eats” spaces of greater than one in normal text. So if you type this in a Forum Editor:_..
My________Text_______with_______Spaces
_.. then after posting, what you “see” will be this:
My Text with Spaces.
There two ways to overcome this problem:
_1) Use the “white character trick”, using the color white: Type this in the Forum editor:
My[color=white]________[/color]Text[color=white]_______[/color]with[color=white]_______[/color]Spaces
On posting you will see this:
My________Text_______with_______Spaces
If you look very carefully you may see this:
My________Text_______with_______Spaces
What you are doing with the “white character trick” is simply displaying white text on a white background.
_2) Code tags preserve spaces. So post your text in the Forum Editor Window in Code tags thus:
[code]My________Text_______with_______Spaces[/code]
This will then come out thus:
Code:
My Text with Spaces
Note , Use of the Code tags can be very useful to compress , or make tidy, long text extending to the right. – The text can be effectively “hidden” to the right, and only viewable by use of the horizontal scroll bar. *1
Similarly, large tables and text can be compressed and only viewable by transgressing with the vertical scroll bar *2
_................................
The next posts discus some extra codes allowing easier manipulation of BB Code in a word document as a further way prepare a Forum Reply. This prepared text could then be copied across to a Forum Editor before posting the Reply. This has been getting more popular recently
'_- Rem ref:
'_- http://www.excelforum.com/the-water-...tra-space.html
'_- https://www.mrexcel.com/forum/about-...ml#post4369692
'_- https://www.mrexcel.com/forum/about-...-%60-o00o.html
'_- *1 https://www.mrexcel.com/forum/about-...ml#post4466491
'_- *1 http://www.excelfox.com/forum/showth...ments#post9696
'_- http://www.excelfox.com/forum/showth...Formating-Test
'_- *2 http://www.excelforum.com/developmen...ml#post4513357
'_- *2 http://excelmatters.com/excel-forums/#comment-199348
'_- https://www.mrexcel.com/forum/about-...ml#post4752733
-
BB Code Generating and Removing. Preparing Forum Post in Word.
Sample Codes
The codes in this Word File, I will probably update from time to time, but the Link will probably stay the same:
“eileenslounge.docm”
https://app.box.com/s/mtwz5jil0p5nbymqrb1cgszjuyg94bea
I actually transfer all my current macros that are to do with using Microsoft Word to prepare a Forum post into the code module “NormalCodesBackUp”.
They come from where I always start putting my macros which is in some default code module God knows where which I never named or created and is in some File I never named or created called “Normal”.
The code module is called NewMacros. I do not have much experience with Word VBA, and my first codes were just done by having the macro recorder turned on whilst manually doing what I wanted. After that I modified the codes a bit and they have been available since to anything I do in word.
NormalMacros.jpg http://imgur.com/TV5YnJ8
Some codes are very simple, so explaining them all may be a bit tedious. I will just go through a few examples. ( I tend to explain a lot in the '_- Green 'comments going off to the right. )
Simple codes for putting single BB Code Code tags pairs in
I mostly got these from a macro recording done while I did what I wanted manually. Then I had some help here http://www.eileenslounge.com/viewtopic.php?f=26&t=25185 http://www.eileenslounge.com/viewtopic.php?f=44&t=26076 to refine them a bit
One further very useful thing I picked up here http://www.eileenslounge.com/viewtop...=25188#p195442 is that you have available an extended range of short cut keys which you can use to trigger off a macro.
The start point of most of my codes are to select the text to which a code pair should be added
So say in my Word File I want to change the text,
'comments
to look in my word document as
[color=green]'comments[/color]
This will return me in a final posted Reply in a Thread the following:
'comments
( Note: I am putting the format, ( here coloring green ) , into the Word document of the same formatting that the BB Code Code tag pair will produce in the final forum post )
So I select that text and use in thes case the short cut keys of first
Ctrl+Shift+g
Followed by ( the extended option )
1
This is the code that does this, ( and there may be lots of better ways to do it):
Code:
Sub Makro10BBGreen() ' Ctrl+Shift+G,1 https://eileenslounge.com/viewtopic.php?f=26&t=25185#p195286
' Let Selection.Font.Color = 5287936 'Green
' Dim rng As Range: Set rng = Selection.Range
' Dim Txt As String
' Let Txt = rng.Text
' 'Let Txt = "" & Txt & " " 'Added a " " space on the end, so that at end of selection is where I want to be or..
' Let Txt = "" & Txt & ""
' Let rng.Text = Txt
' rng.Select ' Select so that I can ...
' Selection.Collapse Direction:=wdCollapseEnd ' ... "unselect" with an option that takes me to the end of the text
' Selection.Font.Color = wdColorAutomatic ' Put text color back to automatic
' Set rng = Nothing
'Or
With Selection
.Font.Color = 5287936
.Text = "" & .Text & ""
.Collapse Direction:=wdCollapseEnd
.Font.Color = wdColorAutomatic
End With
End Sub
This shows the short cut combination, which is ExPlained in a bit more detail here: http://www.eileenslounge.com/viewtop...=25188#p195293
http://wordribbon.tips.net/T008058_A...rtcut_Key.html
_1 Display the Word Options dialog box. (In Word 2007 click the Office button and then click Word Options. In Word 2010 and Word 2013 display the File tab of the ribbon and then click Options.)
_2 At the left side of the dialog box click Customize (Word 2007) or Customize Ribbon (Word 2010 and Word 2013).
_3 Near the bottom of the dialog box click the Customize button. Word displays the Customize Keyboard dialog box.
_4 Scroll through the Categories list and select the Macros category. The list at the right side of the dialog box changes to show the currently available macros.
_5 In the Macros list, select the macro you want assigned to the shortcut key.
_6 With the insertion point in the Press New Shortcut Key box, press the shortcut key you want to use. For instance, if you want to use Ctrl+Alt+J, press that.
_7 Just below the Current Keys box you can see whether the shortcut key is already assigned to a different function.
_8 Click on Assign.
( _ I think 7 should read _7 Just to the Left of the Keys…… )
Note the extended options _..
Green1ShortCut.JPG http://imgur.com/zpOZljD
_..you write in Ctrl+Shift+G and then 1. You do not type in a comer , that is done for you. You also do not type in a comer when you use the keys.
Codes for white Space Tricks.
In the first post was discussed the problem with Forum Editors typically “eating” spaces in the posted Reply. I wrote a number of codes, developed here:
http://www.eileenslounge.com/viewtopic.php?f=26&t=22603 http://www.excelforum.com/the-water-...ml#post4329068 to do the “white space trick”
They are discussed in detail in those referenced threads.
BB Code Table Generator ( Spreadsheet screenshot copyable to a Forum Post )
Using Excel 2007 32 bit
Worksheet: Tabelle3
'_- Here just a few Posts
http://www.excelfox.com/forum/showth...=9821#post9821
http://www.excelfox.com/forum/showth...-BB-Code/page3
http://www.excelforum.com/developmen...ml#post4513357
http://www.excelforum.com/suggestion...ml#post4355361
http://www.excelforum.com/the-water-...ml#post4355240
http://www.excelforum.com/excel-prog...ml#post4399581
http://www.excelforum.com/the-water-...ml#post4109080
Here is a File where I collected lots of such Tools, all as stand codes rather than Add-ins.
Included are also versions of Rory’s Tool as a simple code.
https://app.box.com/s/zhz7awdag4nl1zs6564s9zzcwp50e4w9
( Note: There is a separate Tool for Eileen’s lounge. In the file is a version for Excel. It is derived from Tools from Hans ( Excel and Word ) http://www.eileenslounge.com/viewtopic.php?f=50&t=1421 http://www.eileenslounge.com/viewtopic.php?f=50&t=2121 )
Codes to remove BB Code in text:
I may discuss these in a bit more detail, just to get the documentation down some where, as I only did it all recently.
Such codes may be of limited use. I needed to do it after a Forum Hic cup wiped out a massive amount of my threads , which I only have as a back up in text including BB Code.
I have
_ a long complicated code, that I did myself, that just works on a simple monochrome text string of the entire text.
and
_ a more sensible code which I got some help with. This will take out the BB Code Code tags but leave the text in the Format it has in the Final Thread. That is to say, the form given by the code looks in Word just as it did in the final form in the Forum post. ( Note, however, that this is only possible as the codes for putting single BB Code Code tags pairs which I used also put the corresponding format into the text in a Word document in the first place )
-
VBA Remove BB Code Code Tags in text. Long way around of doing it :)
VBA Remove BB Code Code Tags in text
In the next post is a code to remove BB Code Code Tags in text
This code is slightly redundant since I was given a simpler one ,
http://www.eileenslounge.com/viewtop...202145#p202122
which probably is more Full proof !
But I include it here with description for future reference. I may use it in a following code or codes to cross check the results given.
The code is intended to remove valid BB Code Code Tag sections from a Text string.
In this case, valid means in terms of the syntax, which is basically as follows
[TagWord=Some]Any text[/TagWord] or [B]Any text[/b]
An arbitrary string is given initially in code section Rem 1)
"gggg[d=fg]2[/d]45[/8]x[ddd[Cl=XYZ][/Cl][B]Any text[/b]"
Then the main code is as follows
Rem 2 Brief Code description
The code works backwards 100 through the whole string. It looks at a character at a time.
120 __ On If finding a ] , it notes the position of it,
140 BcrdEEnd, then keeps going back.
160___If it finds another it notes that as the ] position and carries on going back.
170 It determines the position of a [ , BcrdESt, by looking for a [\
It starts looking again for the next ] ,
250 _____If a ] is found, it checks
260 _____If the next character back is another ], Then it keeps going back. If the next character back was Not a ] , then the position of the ], BcrdSEnd, is
270 noted
A new last loop 290 starts going further back to look for a [
300 ________If it finds a [ , it notes that, BcrdSSt.
320 ________If in the unlikely event that it is a start of an end , like [\ then we have found a second End BB Code Code Tag so we do like_..
BcrdEEnd = BcrdSEnd:
BcrdESt = BcrdSSt:
BcrdSEnd=0:
( BcrdSSt=0 )
_..and go back and start again looking for the start tag. Otherwise the start position of the start tag, BcrdSSt, is noted, then it is finally time to go and think about getting rid of the code tag pair whose positions have now been determined....
430 FkOffCrd:
_..So I come to a point, aptly named, Rem 3) "I think we come here with a complete set of 4 positions". So I try to take the BB Code Code Tags out. As I am going backwards, the new string with the missing Code Tag pair does not mess up me going through the characters as I took off stuff "behind me"
450 I overdo the use of variables here because I can and do, but also because a development of the code might be to look through a list of available BB Code Code Tags to check I have them . I do one quick validity check: I check that the word after the / in the End BB Code code tag is the same as the word in the start BB Code code tag ( that before an = , if there is an = ) . Only
500____ If this condition ( which must be met for a valid BB Code code tag ) is met are the pair of tags removed by replacing them with , . Another condition is also checked: a / in second character of the stop tag.
Either from going through a code section search with possible removal, or ,
540 Else not , we are at the Next posCurrent of the main going backward Loop,
580 , so keep going back looking for another, or a first possible start ( looking from the back ).
Hopefully, for example at line 340, posCurrent would have been reduce to allow for the inner Loops going back in a code tag section search.
_................................
The code returns the string:
gggg245[/8]x[ddd[B]Any text[/b]
-
Code described and ExPlained in last post
Code:
Sub LongWayOfDoingIt()
10 Rem 1) Test string
20 Dim strBBCode As String '
30 Let strBBCode = "gggg[d=fg]2[/d]45[/8]x[ddd[Cl=XYZ][/Cl]]Any text"
40 Dim strRmveBBCode As String: Let strRmveBBCode = strBBCode ' This will be adjusted until finally has no BBCode tag pairs
50 Dim Lstr As Long ' This will be adjusted as necerssary for current length ' Long is very simple to handle, - final memory "size" type is known (123.456 and 000.001 have same "size" computer memory ) , and so a Address suggestion can be given for the next line when the variable is filled in. '( Long is a Big whole Number limit (-2,147,483,648 to 2,147,483,647) If you need some sort of validation the value should only be within the range of a Byte/Integer otherwise there's no point using anything but Long.--upon/after 32-bit, Integers (Short) need converted internally anyways, so a Long is actually faster. )
60 Let Lstr = Len(strBBCode)
70 Rem 2) Loop through and get a BB Code section
80 Dim strBBCodePair As String ' for a found valid pair '
' Prepares "Pointer" to a "Blue Print" (or Form, Questionaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular “Value”, or (“Values” for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. A String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quich checks.. But..http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring-2.html#post44116
90 Dim posCurrent As Long 'Current position in the string' Loop Bound variable Count '_-Main Loop==========================
100 For posCurrent = Lstr To 2 Step -1 'Important to go backwards as we chop off behind us so have a less complicated current position. We look at pos-1 in some code parts so we would error if we went back to less than 2
110 '2a) Check for a ] Most likely a end of end tag ' ---Loop To find ]
120 If Mid(strRmveBBCode, posCurrent, 1) = "]" Then
130 Dim posBBCodeTagSrch As Long '
140 Dim BcrdEEnd As Long: Let BcrdEEnd = posCurrent 'Position of possible End Code Tag End ' ---Loop To Find [/--
150 For posBBCodeTagSrch = posCurrent - 1 To 2 Step -1 'PosCurrent is set here at loop start. ###It is not effected by cardinally sining changing PosCurrent Loop Bound variable caount in Outer main Loop
160 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "]" Then Let BcrdEEnd = posBBCodeTagSrch: GoTo NxtCESPosPos ' If we hit another ] then change the stop tag stop character position and start again to see if is a valid BB code section
170 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "/" And Mid(strRmveBBCode, posBBCodeTagSrch - 1, 1) = "[" Then 'We hit start of a BB Code end tag
180 Dim BcrdESt As Long: Let BcrdESt = posBBCodeTagSrch - 1 'Position of End Code Tag Start
190 Exit For ' We leave this For the End Code Tag Start Search, Exit For with a [ at posBBCodeTagSrch-1
200 Else 'Not found start of end Tag or stop of end Tag.
210 End If
220 NxtCESPosPos: Next posBBCodeTagSrch ' go back in possible BB code string ' ---End Loop to find [/---------------------
230 If posBBCodeTagSrch = 3 Then Exit Sub 'case we never found the start of an End Code Tag
235 '2b) Check for a ] Most Likely end of start tag ' ---Loop to find ]
240 For posBBCodeTagSrch = posBBCodeTagSrch - 2 To 2 Step -1 ' Once again ### the start is set and fixed, the Loop Bound Variable Count will change
250 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "]" Then
260 If Mid(strRmveBBCode, posBBCodeTagSrch - 1, 1) = "]" Then GoTo NxtCSSPosPos ' If we hit another ] then start again to see if is a valid BB code start section
270 Dim BcrdSEnd As Long: Let BcrdSEnd = posBBCodeTagSrch 'Position of possible Start Code Tag End
280 Dim LTagStLoop As Long 'Last loop to find start of start Code Tag
290 For LTagStLoop = posBBCodeTagSrch - 1 To 1 Step -1 '_-Most Inner loop_______to find [/____________
300 If Mid(strRmveBBCode, LTagStLoop, 1) = "[" Then
310 Dim BcrdSSt As Long 'Have to put it here, - I may occaisionally have to set it to 0 in next line
320 If Mid(strRmveBBCode, LTagStLoop + 1, 1) = "/" Then Let BcrdEEnd = BcrdSEnd: Let BcrdSEnd = 0: Let BcrdESt = LTagStLoop: Let BcrdSSt = 0: Let posBBCodeTagSrch = LTagStLoop: GoTo NxtCSSPosPos ' Found a second end Code Tag. So change the previous found start and stop , and adjust the Loop Bound variable Count appropriately for a new search for a start Code Tag
330 Let BcrdSSt = LTagStLoop
340 Let posCurrent = BcrdSSt 'End of Code Tag section search
350 GoTo FkOffCrd ' We leave this For the start Code Tag Start Search and go to Fuk Off Crd:
360 Else ' Still looking for start of start Code Tag
370 End If
380 Next LTagStLoop '_- End Most inner loop_____________________to find [/_____________________________
390 If LTagStLoop = 1 Then GoTo TheEnd 'Case I think we failed to find a start start [ for the complete possible Code Tag section search
400 Else 'Not found end of start Tag or start of start Tag
410 End If
420 NxtCSSPosPos: Next posBBCodeTagSrch ' go back in possible BB code string' ---End Loop to find ]
425 If posBBCodeTagSrch = 0 Then GoTo TheEnd ' For any outer search failed to find a ] at all or a search for matching start tag that was fruitless
430 FkOffCrd: Rem 3) "I think we come here with a complete set of 4 positions"
440 If BcrdEEnd <> 0 And BcrdESt <> 0 And BcrdSEnd <> 0 And BcrdSSt <> 0 Then 'Just to check'
450 Dim SttBcrd As String, StpBcrd As String ' Start and stop tags as coplete strings including [ and ]
460 Let SttBcrd = Mid(strRmveBBCode, BcrdSSt, BcrdSEnd - BcrdSSt + 1) ' ' like |Color=Red|
465 Let StpBcrd = Mid(strRmveBBCode, BcrdESt, BcrdEEnd - BcrdESt + 1) ' ' like |/Color|
470 Dim SttWrd As String, StpWrd As String
480 Let StpWrd = Mid(StpBcrd, 3, Len(StpBcrd) - 3) ' like Color from |/Color| - Whole Word, from 3rd Chr , for Length as WholeWord-3
490 Let SttWrd = Mid(SttBcrd, 2, Len(StpWrd)) ' like Color from |Color=Red|
500 If UCase(SttWrd) = UCase(StpWrd) And Mid(StpBcrd, 2, 1) = "/" Then 'Ucase allows for differences in cases And Mid(SttBcrd, Len(SttWrd) + 2, 1) = "=" Then
510 Let strRmveBBCode = Replace(strRmveBBCode, SttBcrd, "", 1, 1) ' Replace in ( strRmveBBCode , the start tag , with no string , start loooking from and return from character 1 )
515 Let strRmveBBCode = Replace(strRmveBBCode, StpBcrd, "", 1, 1)
520 Else 'No shortening of string for non matching tag word
530 End If
540 Else 'No shortening of string for not all 4 [ and ] found. Not sure if I ever come here..
550 End If
560 Else ' no last ] of a possible Code section yet, so keep going back down in the main string , main loop
570 End If
580 Next posCurrent '_-===Main Loop========================================================================================
590 TheEnd:
600 MsgBox Prompt:="" & strRmveBBCode & "": Debug.Print "" & strRmveBBCode & "" 'Hit Ctrl+g when in VB Editor Window, reveal Immediate window after code run
End Sub
-
Wild Things. You make my heart sing. They make everything.....Groovy ........ :)
The VBA code in the last few posts is a bit of a long way around of doing what can be done in a Word Dialogue box type thing using Wild things:
http://www.gmayor.com/replace_using_wildcards.htm
http://imgur.com/4Nqj1HP
The problem is getting at the Wild Things needed in the Wild Find String.
I can't do it. But Hans and Paul did it for me here:
http://www.eileenslounge.com/viewtop...=26030#p202107
Here is my attempt at an 'ExPlanation of the solution:
Wild Things. You make my heart sing. They make everything….. Groovy
Wild Things. You make my heart sing. They make everything….. Groovy
http://listenonrepeat.com/watch/?v=H...s_-_Wild_Thing
Wild things…. I think I hate you .. But I wanna know for sure… so
A Summary :)
As example. We want to remove the start and stop tags in a sample string containing a start and stop tag such as this_..
[color=Green]This is green[/color] This 'aint matey
_.. What we finally want is this:
This is green This 'aint matey
We use a combination of Wild things , or like a pattern to search for [ Find ] any bits like _..
[color=Green]This is green[/color]
_.. and [ Replace ] that "Find"ed with
This is green
We can do, it Wildly, man, as follows:
As always the search is done from left to right
The way I do it below is probably not the most efficient way, in fact it is probably pretty stupid, but is just to demo the idea
Optional use of ( ) in the Wild thing search string
We can use brackets ( ) , optionally , to identify, ( for later use ) , the exact string parts found by the constituent Wild things in the ( ) in which they are in:
So in this example we will use a ( ) for
_ the Wild things that find the color so that the actual word color can be used again in the same wild stuff string, so as to make sure that we find in the end tag the matching word to that in the start tag.
_ Also we need a ( ) to identify the wild things that Find This is green , as we want to use that in , or rather for the complete, Replace string.
A bracket is identified by , for example, \2 if I want to reference the actual string found by the wild things we enclose in the second ( )
Build up final Wild thing Replace string, left to right, by breaking string we want up into bits. Each bit will be found by a Wild thing or things
So we are looking to break the to search for Wild [ Find ] Thing string down thus:
Code:
[ & ( AnythingWithout=or] ) & anything & ] & (Anything) & [\ & \1 & ]
So I am breaking it down in to 8 bits. So I need 8 sections of wild stuff to Find those.
\1 is at the 7th position and refers to what is actually found by the search for ( AnythingWithout=or] ) at position 2 ( which is bracket ( ) number 1 )
Excel starts at the left. What no literature really states clearly ( and is only obvious once you know it ) is this:
_ For most sections, Excel keeps going to the right until it Finds what the Wild thing tells it to. That is then stored, but only if that found string also has joined to it the string type in the next section's Wild thing. Those two sections are then stored ( as well as storing separately if either of those two sections are enclosed in ( ) ), but only if that found string also has joined to it the string type in the next section's Wild thing. That is then stored, but only if that found string also has joined to it the string type in the next section's Wild thing. ……..etc.
A common Wild thing is * . This means anything characters and any amount. This will only include, however, anything up to if and when the next Wild thing is satisfied.
The 7th Wild thing I already have which is \1 which is referring to the 1st bit enclosed in a ( ) , which is the second bit in the broken up string , ( which is anything without a = or a ] . In our example this will be color) . Note: The number refers to the number from the left of any ( ) that I may have included, not the actual sections.
Just to make that last point clear, and to demonstrate another, I will do this_..
Code:
[ & ( AnthingWithout=or] ) & ( Anything & ] ) & (Anything) & [/ & \1 & ]
_.. so my Replace is then \3 . I do not need the second ( ___ ) , which I could reference by \2, ( and it can help to result in an "expression too complex" error ! ).
I put the second ( ___ ) in also to demo that a ( __ ) can include more than one wild bit
So here is one example Find sting with Wild things that "works" ( I added spaces to show better the 8 sections, but in use those spaces must be removed ). There are three optional ( ) sections. The second ( ) section encloses two Wild thing sections: Those are the third and forth counting from the left.
Code:
[\[] ([!\]=]@) (* \]) (*) \[/ (\1) \]
This is the actual Wild Find string
___ [\[]([!=\]]@)(*\])(*)\[/(\1)\]
To '_- ExPlain the 8 parts:
Part 1 [\[]
Excel start "looking" from the left to find a [
As a general rule Wild things are enclosed in a [ ] pair to identify them as such. So a [ ] is a Wild thing. They do not always have to be enclosed in a [ ], as is the case here. Here we are effectively looking to Find a single simple character, [.
( In the final Find string, only the second Wild section needs to be enclosed partly in a [ ] pair ).
So this section written as \[ instead is just as good. I suspect my use of the extra [ ] here does not have any bad effects, as it might be that the final string would be at compile or whatever reduced to \[ in either use of \[ or [\[]
We need to use the Wild thing, \ , quite a bit , in our total string for the same reason that we do here: This is because the \ has another use in Wild things in addition to the already discussed way like \7 ( where 7 would be for the 7th ( ) ). This other use of \ is to allow us to use characters as simple text which have a specific use in Wild things, so that Excel knows that we want to use them as their literal text string, rather than as Wild thing. Here it is needed for the first [ which we want to find.
( It follows that if we were looking for a \, then we would need to use \\ )
In our example string we find with this first Wild thing section the first [
Part 2 ([!\]=]@)
As noted the ( ) allows the string actually found in this Wild bit to be used later to the right via the reference \1.
As for this:
[!\]=]@ ( which could just as well be written [!=\]]@ )
We need a [ ] pair here, as within that is part of the Wild instructions for what to search for , and that has a further Wild instruction, @ , applied to that.
So in such a [ ] pair we would normally expect some specific wild stuff
Here the Wild thing, ! , means we search for any character other than those after included up to the closing tag ]. In our sample string , our first Wild bit found the first [ which now has added on any string at the next character if it is not a = or a ]
So this part of the second wild bit will find c in our sample string. If we had no other wild instructions here, then Excel would be content/ satisfied with that c. That would be joined on to the first [ found, so our result so far would be [c . In effect Excel stops going to the right when it is satisfied, and goes on to the next Wild bit. But we have another wild instruction here: The @ instructs to look for any amount of characters meeting the conditions before it, in this case the conditions in the [ ]. So the "Find" will stop finding characters when it no longer has a not = or a not ]. In our sample string the characters meeting the conditions are tacked on to a [ so will be will be [color. What [!\]=]@ has actually found and what the brackets ([!\]=]@) can be thought of as "holding" is color.
An alternative for @ would be {1,} which looks for between 1 and any amount of what is before it.
If we had used {1,4} or {2,4} instead of @ we would have so far for the complete found string [colo
If we had used {5,5} we would not have found a matching code tag word with less than 5 characters.
Parts 3 and 4 (*\])
This is unnecessarily in ( ) . *\] will do
The literature says * looks for any amount of anything. I think that is not strictly correct, or at least, explains it badly. It would appear to look for any amount of anything only until the next wild condition is met. That is why I chose to put it in ( ) just to demo the dependence, as it were. But this (*)(\]) or this *\] would work just as well (*)(\]).
Once again the \ is required for telling Excel that we want it to recognise ] as a string rather than a specific Wild thing. For this section , with my example string, I get from this complete 2 part Wild section
=green]
If our code tags were of the form like: [b]SomeBoldText[/b] , then the search would have "stopped before it started", as it were, as the ] would have "stopped" it
The combination of the 2 part Wild sections in this case would return just the single text character ]
Parts 5 and 6 (*)\[/
I contradict what I said in the last section slightly by using a ( ) around the * . Once again the * does nothing useful without the next wild bit to "stop" it. But what it does Find before it "stops" is what we actually need for Replace string. Hence I need a ( ) to reference what it Finds. This total Part 5 and part 6 section returns in our example
This is green[/
and the part referenced inside the ( ) is
This is green
Part 7 (\1)
As discussed already here the Wild thing, \1 , instructs to Find a string equal to that actual text found in the first ( ) if it is just before the next to be found ( which we will see in the next Part is the last character pair found, [/ ). The actual string found by [!\]=]@ in Part 2 , was , in our example the text color
Part 8 \]
Finally only a complete final Find attempt is successful if the last character is a ] , that is to say if the character after the text, in our example, the second color, is a ]
_...
The Final "Find"ed String for our example would be
[ & color & =Green & ] & This is green & [/ & color & ]
-
Simple code to use the Find and Replace discussed in the last Post
Here is a simple code to use the Find and Replace discussed in the last Post
The code should go in a code module in a WORD .docm File
Before rung the code, a text which includes BBCode Code Tags , should be selected in a Word document.
The Code makes a temporary File, "TempBBCodeCopy1.docx", holding the original selected text, then removes the BB Code Code Tags from the text and saves that as another temporary File, "TempNoBBCodeCopy2.docx"
Code:
Sub WegDaMitHansPaulAlan() ' http://www.eileenslounge.com/viewtopic.php?f=26&t=26030#p202223
Rem Code Part 1) make two temporary Word Files with and without BB Code
Rem 1) Copy selection to Clipboard
Selection.Copy
Rem 2) Make temporary WORD document
Documents.Add: ActiveDocument.Content.Paste
' 2b) Copy of Full Text with BB Code
Dim FullFilePathAndFullNameBBCode As String
ActiveDocument.SaveAs Filename:="TempBBCodeCopy1.docx", FileFormat:=wdFormatXMLDocument
Let FullFilePathAndFullNameBBCode = ActiveDocument.Path & "\" & ActiveDocument.Name
Rem 3) Replace Code tag pairs with what is in between
Selection.WholeStory
With Selection.Find
.ClearFormatting: .Replacement.ClearFormatting
.Wrap = wdFindStop
.MatchWildcards = True '
.Text = "[\[]([!=\]]@)(*\])(*)\[/(\1)\]" ' 8 sections, 4 identified with ( ) but I only need two ( )
.Replacement.Text = "\3" ' The third of the 4 sections identified with a ( )
.Execute Replace:=wdReplaceAll
End With
' 3b) Copy of Colored Text without BB Code Code tags
Dim FullFilePathAndFullNameNoBBCode As String
ActiveDocument.SaveAs Filename:="TempNoBBCodeCopy2.docx", FileFormat:=wdFormatXMLDocument
Let FullFilePathAndFullNameNoBBCode = ActiveDocument.Path & "\" & ActiveDocument.Name
Rem 4) "Reset the "Find Replace Text Dialogue" "Thing" "
ActiveDocument.Select
Selection.WholeStory
With Selection.Find
.ClearFormatting: .Replacement.ClearFormatting: .Text = "": .Replacement.Text = "": .Forward = True: .Wrap = wdFindAsk: .Format = False: .MatchCase = False: .MatchWholeWord = False: .MatchKashida = False: .MatchDiacritics = False: .MatchAlefHamza = False: .MatchControl = False: .MatchWildcards = False: .MatchSoundsLike = False: .MatchAllWordForms = False '
End With
Rem 5) Option to close / kill document
ActiveDocument.Close (wdDoNotSaveChanges)
'Kill FullFilePathAndFullNameBBCode
'Kill FullFilePathAndFullNameNoBBCode
End Sub ' End Code Part 1)
__________________________________________________ _______________________________________
This not too relavent for this Post, just wanted to jot it down quick:
Code:
'EP Dim: For Object variables: Address location to a "pointer". That has all the actual memory locations (addresses) of the various property values , and it holds all the instructions what / how to change them , should that be wanted later. That helps to explain what occurs when passing an Object to a Call ed Function or Sub Routine By Val ue. In such an occurrence, VBA actually passes a copy of the pointer. So that has the effect of when you change things like properties on the local variable , then the changes are reflected in changes in the original object. (The copy pointer instructs how to change those values, at the actual address held in that pointer). That would normally be the sort of thing you would expect from passing by Ref erence. But as that copy pointer "dies" after the called routine ends, then any changes to the Addresses of the Object Properties in the local variable will not be reflected in the original pointer. So you cannot actually change the pointer.)
'EP Set: Fill or partially Fill: Setting to a Class will involve the use of an extra New at this code line. I will then have an Object referred to as an instance of a Class. At this point I include information on my Pointer Pigeon hole for a distinct distinguishable usage of an Object of the Class. For the case of something such as a Workbook this instancing has already been done, and in addition some values are filled in specific memory locations which are also held as part of the information in the Pigeon Hole Pointer. We will have a different Pointer for each instance. In most excel versions we already have a few instances of Worksheets. Such instances Objects can be further used., - For this a Dim to the class will be necessary, but the New must be omitted at Set. I can assign as many variables that I wish to the same existing instance
'_-So A variable in VBA is like the Link to the part of a URL string reducing size site where a few things about the actual Final site is informed about. This area in that site, like a pigion Hole to which the variable refers, ( the "pigeon hole" location address, and all its contents would be defined as the "Pointer". Amongst other things it has a link, a "Pointing part", pointing to actually where all the stuff is
-
Full Code "Belt and Braces” Word Find Replace & string manipulation
Full Code "Belt and Braces" in Word Find Replace & String Manipulation of initial Text String in Clipboard
This code is simply doing the two ways to remove BB Code code tag pairs from a copied to the clipboard Text from a Word document.
A check is then done Finally to see if the two raped from tags strings are the same.
I would not be surprised if a fail in the strings match just means that the second method, ( my long string manipulation way ) is getting it wrong.. Lol.. but never mind :) ***
***Edit: - like I just did: It will not work for nested BBCode code tags like
[CENTER][B]Issue Forum for Issues suggestions for improvement Forum for Issues obfuscation[/B][/CENTER]
This is OK
[B]Issue Forum for Issues suggestions for improvement Forum for Issues obfuscation[/B]
:rolleyes:
That will do for this one, I guess I will have to do a recursion wonk to get a version working with nested BB Code Tag code tags,
_.____________-
:rolleyes:
Ok. Here we go:
This code _..
Sub BBCodeCodeTagsWegDaMit2AlanHansPaul2()
_.. is mostly just splicing together codes
Sub WegDaMitHansPaulAlan()
and
Sub LongWayOfDoingIt()
along with adding a short section, Rem 10a) to check that the strings are the same. That is to say the
Full Story selection text from the modified ( removed BB Code code tags ), NewWordText for Code Part 1)
is
compared with the final RapedText from the long string manipulation Code part 2)
The code is all one code and broken down into this and the next three posts
Code part 1 of 4 parts ( all following parts to be copied directly under the preceding part in the same code module.
Code:
Sub BBCodeCodeTagsWegDaMit2AlanHansPaul2() ' http://www.excelforum.com/development-testing-forum/1086445-forum-tools-test-no-reply-needed-4.html#post4586680
' === Code assumes you have a Word File open, and have selected some Text
' One way is automating doing it in Word. "Wild Things. You make my heart sing. They make everything….. Groovy" '_- http://www.eileenslounge.com/viewtopic.php?f=26&t=26030#p202322
Rem 0) ' Just mucking about a bit with refering to Word documents
' Documents.Item("eileenslounge.docm").Activate
'Dim DocNme As String ' ' Prepares "Pointer" to a "Blue Print" (or Form, Questionaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular "Value", or ("Values" for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. A String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quich checks.. But..http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring-2.html#post44116
' Let DocNme = ActiveDocument.Name ' ' '_-So A variable in VBA is like the Link to the part of a URL string reducing size site where a few things about the actual Final site is informed about. This area in that site, like a pigion Hole to which the variable refers, ( the "pigeon hole" location address, and all its contents would be defined as the "Pointer". Amongst other things it has a link, a "Pointing part", pointing to actually where all the stuff is
Dim Doc As Document 'A variable in VBA is like the Link to the part of a URL string reducing size site where a few things about the actual Final site is informed about. This area in that site, like a pigion Hole to which the variable refers, ( the "pigeon hole" location address, and all its contents would be defined as the "Pointer". Amongst other things it has a link, a "Pointing part", pointing to actually where all the stuff is
Set Doc = ActiveDocument 'EP Set: Fill or partially Fill: Setting to a Class will involve the use of an extra New at this code line. I will then have an Object referred to as an instance of a Class. At this point I include information on my Pointer Pigeon hole for a distinct distinguishable usage of an Object of the Class. For the case of something such as a Workbook this instancing has already been done, and in addition some values are filled in specific memory locations which are also held as part of the information in the Pigeon Hole Pointer. We will have a different Pointer for each instance. In most excel versions we already have a few instances of Worksheets. Such instances Objects can be further used., - For this a Dim to the class will be necessary, but the New must be omitted at Set. I can assign as many variables that I wish to the same existing instance
Rem Code Part 1) make two temporary Word Files with and without BB Code
-
Code part 2 of 4 parts
Code part 2 of 4 parts
Code:
Rem Code Part 1) make two temporary Word Files with and withouut BB Code
Rem 1) Copy selection to Clipboard
Selection.Copy
Rem 2) Make temporary WORD document 'Bit of a bodge to get the text in a selection: create a Word file and paste to it
Dim NextTempDoc As Document '
Documents.Add: ActiveDocument.Content.Paste 'Make a File Copy in current Application based on Default Type : And Paste from Clipoard ( ...!!!...our original selected text ) using the Default Copy which should at least have all the text, which is all we are interested in here.
Set NextTempDoc = ActiveDocument ' Do this in case i muck about- I do not want to inadvertently close or kill the wrong document
'2b) Copy of Full Text with BB Code
Dim FullFilePathAndFullNameBBCode As String ' 'Prepares "Pointer" to a "Blue Print" (or Form, Questionnaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular “Value”, or (“Values” for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quick checks.. But...http://www.mrexcel.com/forum/excel-q...html#post44116
NextTempDoc.SaveAs FileName:="TempBBCodeCopy1.docx", FileFormat:=wdFormatXMLDocument 'Without this the document will not really "exist jet". It has a tempory name ( Used in Windows referrence ), but no path.
Let FullFilePathAndFullNameBBCode = NextTempDoc.Path & "\" & ActiveDocument.Name
Rem 3) From Han's Text Find Replacement Dialogue 'http://www.eileenslounge.com/viewtopic.php?f=26&t=22603#p175712
'3a) Take out all BB Code
Selection.WholeStory 'Selects whole document which here is just our selection of interest from the original document
Dim StrOrg As String: Let StrOrg = Selection.Text '11a)6b)' Original Text to use in string manipultion code of Code Part 2)
With Selection.Find 'This is the VBA code ( or very similar ) used by Excel when Using the Find eplace text Dialogue box. So this is an improved version of what a macro recording would give.
.ClearFormatting: .Replacement.ClearFormatting ' Don't use formating, ? not sure this comes into the equation ??
.Wrap = wdFindStop ' Tell Word not to continue past the end of the selection ( And therefore prevents also a display Alert asking )
.MatchWildcards = True
.Text = "[\[]([!=\]]@)(*\])(*)\[/(\1)\]" ' 8 sections, 4 identified with ( ) but I only need two ( )
.Replacement.Text = "\3" ' The third of the 4 sections identified with a ( )
.Execute Replace:=wdReplaceAll ' Replace all within selection. This is the "OK" button!
End With
Selection.WholeStory: Dim NewWordText As String: Let NewWordText = Selection.Text '´11a) New text for comparison with result from Code Part 2)
'3b) Copy of Colored Text in Word File without BB Code Code tags
Dim FullFilePathAndFullNameNoBBCode As String
NextTempDoc.SaveAs FileName:="TempNoBBCodeCopy2.docx", FileFormat:=wdFormatXMLDocument 'Without this the document will not really "exist jet". It has a tempory name ( Used in Windows referrence ), but no path.
Let FullFilePathAndFullNameNoBBCode = NextTempDoc.Path & "\" & ActiveDocument.Name
Rem 4) "Reset the "Find Replace Text Dialogue" "Thing" ". if you do not there may be some changed setting there that could catch you out next time you use it.
NextTempDoc.Select ' Re select the...( actually this line alone seems to do it )
Selection.WholeStory '...whole document
With Selection.Find
.ClearFormatting: .Replacement.ClearFormatting: .Text = "": .Replacement.Text = "": .Forward = True: .Wrap = wdFindAsk: .Format = False: .MatchCase = False: .MatchWholeWord = False: .MatchKashida = False: .MatchDiacritics = False: .MatchAlefHamza = False: .MatchControl = False: .MatchWildcards = False: .MatchSoundsLike = False: .MatchAllWordForms = False '
End With
Rem 5) Optiion to close / kill document
NextTempDoc.Close (wdDoNotSaveChanges) ' Giving the option will also prevent being asked for it. You must close. VBA will not let you kill an open sheet, as you are affectively working on a copy, and VBA is assumng the Original can be got at by saving for example. http://www.mrexcel.com/forum/excel-questions/920451-excel-macro-files.html#post4425428
'Kill FullFilePathAndFullNameBBCode ' Use the Kill wisely!!!! - where this goes there 'aint no coming back!!
'Kill FullFilePathAndFullNameNoBBCode
Rem Code Part 2 Put text without BB code into clipboard
Rem 6) Use data Object ( assumes we copied to the Clipboard )
'1 a) Data Object to get the data from the clipboard.
'_- ExPlanation Dim :'_-: For Object variabls: Address location to a "pointer". That has all the actual memory locations (addresses) of the various property values , and it holds all the instructions what / how to change them , should that be wanted later. That helped explain what occurs when passing an Object to a Call ed Fucntion or Sub Routine By Val ue. In such an occurance, VBA actually passes a copy of the pointer. So that has the effect of when you change things like properties on the local variable , then the changes are reflected in changes in the original object. (The copy pointer instructs how to change those values, at the actual address held in that pointer). That would normally be the sort of thing you would expect from passing by Ref erence. But as that copy pointer "dies" after the called routine ends, then any changes to the Addresses of the Object Properties in the local variable will not be reflected in the original pointer. So you cannot actually change the pointer.)
'_- Explanation Set :'_-: Fill or partially Fill: Setting to a Class will involve the use of an extra New at this code line. I will then have an Object referred to as an instance of a Class. At this point I include information on my Pointer Pigeon hole for a distinct distinguishable usage of an Object of the Class. For the case of something such as a Workbook this instancing has already been done, and in addition some values are filled in specific memory locations which are also held as part of the information in the Pigeon Hole Pointer. We will have a different Pointer for each instance. In most excel versions we already have a few instances of Worksheets. Such instances Objects can be further used., - For this a Dim to the class will be necessary, but the New must be omitted at Set. I can assign as many variables that I wish to the same existing instance
'Dim objCliTextCopied As DataObject '**Early Binding. This is for an Object from the class MS Forms. This will be a Data Object of what we "send" to the Clipboard. So I name it CLIpboardSend. But it is a DataObject. It has the Methods I need to send text to the Clipboard
' Set objCliTextCopied = New DataObject '**Must enable Forms Library: In VB Editor do this: Tools -- References - scroll down to Microsoft Forms 2.0 Object Library -- put checkmark in. Note if you cannot find it try OR IF NOT THERE..you can add that manually: VBA Editor -- Tools -- References -- Browse -- and find FM20.DLL file under C:\WINDOWS\system32 and select it --> Open --> OK. http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
' ( or instead of those two lines Dim obj As New DataObject ). or next two lines are.....Late Binding equivalent'
Dim objCliTextCopied As Object ' Late Binding equivalent' If you declare a variable as Object, you are late binding it. http://excelmatters.com/2013/09/23/vba-references-and-early-binding-vs-late-binding/
Set objCliTextCopied = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") ' http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
'6a) Original text string from '11a) The line below means I have nothing to do with the Clipboard yet' - see furhter to the right for .Geting From Clipboard for if it had been in it ' 'Put all? Clipboard Infomation into Data Object
objCliTextCopied.SetText Text:=StrOrg ' I am messing about putting this in data object, then taking it out on 6b) , but I just wanted the code to be more flexible for later use. ' ''objCliTextCopied.GetFromClipboard 'All that is in the Clipboard goes in this Data Object initial instance of the Class This line does not seem to be necerssary for the next Geting Text bit
-
Code Part 3 of 4 parts
Code Part 3 of 4 parts
Code:
'6b) get code as long string String. This can be very long
Dim TextWithBBCodeEnit As String ' 'Prepares "Pointer" to a "Blue Print" (or Form, Questionnaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular "Value", or ("Values" for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quick checks.. But...http://www.mrexcel.com/forum/excel-q...html#post44116
Let TextWithBBCodeEnit = objCliTextCopied.GetText() ''retrieve the text in this instance of the Class. ( Our code as a String with probably BB Code Code tags, vbCr vbLf etc.
Rem 7) Determine length of original text
Dim LenText As Long ' ' Long is very simple to handle, - final memory "size" type is known (123.456 and 000.001 have same "size" computer memory ) , and so a Address suggestion can be given for the next line when the variable is filled in. '( Long is a Big whole Number limit (-2,147,483,648 to 2,147,483,647) If you need some sort of validation the value should only be within the range of a Byte/Integer otherwise there's no point using anything but Long.--upon/after 32-bit, Integers (Short) need converted internally anyways, so a Long is actually faster. )
Let LenText = Len(TextWithBBCodeEnit)
MsgBox prompt:="Text with BB Code Character count is " & LenText
Rem 8) Take out BB Code bits from text string.
40 Dim strRmveBBCode As String: Let strRmveBBCode = TextWithBBCodeEnit ' = strBBCode ' This will be adjusted until finally has no BBCode tag pairs
50 Dim Lstr As Long ' This will be adjusted as necerssary for current length ' Long is very simple to handle, - final memory "size" type is known (123.456 and 000.001 have same "size" computer memory ) , and so a Address suggestion can be given for the next line when the variable is filled in. '( Long is a Big whole Number limit (-2,147,483,648 to 2,147,483,647) If you need some sort of validation the value should only be within the range of a Byte/Integer otherwise there's no point using anything but Long.--upon/after 32-bit, Integers (Short) need converted internally anyways, so a Long is actually faster. )
60 Let Lstr = Len(TextWithBBCodeEnit) ' Len(strBBCode)
70 Rem 2) Loop through and get a BB Code section
80 Dim strBBCodePair As String ' for a found valid pair '
' Prepares "Pointer" to a "Blue Print" (or Form, Questionaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular "Value", or ("Values" for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. A String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quich checks.. But..http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring-2.html#post44116
90 Dim posCurrent As Long 'Current position in the string' Loop Bound variable Count '_-Main Loop==========================
100 For posCurrent = Lstr To 2 Step -1 'Important to go backwards as we chop off behind us so have a less complicated current position. We look at pos-1 in some code parts so we would error if we went back to less than 2
110 '2a) Check for a ]
120 If Mid(strRmveBBCode, posCurrent, 1) = "]" Then
130 Dim posBBCodeTagSrch As Long 'For search through possible valid BBCode Section'_-Loop for Pos tag pair section--
140 Dim BcrdEEnd As Long: Let BcrdEEnd = posCurrent 'Position of possible End Code Tag End
150 For posBBCodeTagSrch = posCurrent - 1 To 2 Step -1 'PosCurrent is set here at loop start. ###It is not effected by cardinally sining changing PosCurrent Loop Bound variable caount in Outer main Loop
160 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "]" Then GoTo NxtCESPosPos ' If we hit another ] then start again to see if is a valid BB code section
170 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "/" And Mid(strRmveBBCode, posBBCodeTagSrch - 1, 1) = "[" Then 'We hit start of a BB Code end tag
180 Dim BcrdESt As Long: Let BcrdESt = posBBCodeTagSrch - 1 'Position of End Code Tag Start
190 Exit For ' We leave this For the End Code Tag Start Search, Exit For with a [ at posBBCodeTagSrch-1
200 Else 'Not found start of end Tag or stop of end Tag.
210 End If
220 NxtCESPosPos: Next posBBCodeTagSrch ' go back in possible BB code string
230 If posBBCodeTagSrch = 3 Then Exit Sub 'case we never found the start of an End Code Tag
240 For posBBCodeTagSrch = posBBCodeTagSrch - 2 To 2 Step -1 ' Once again ### the start is set and fixed, the Loop Bound Variable Count will change
250 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "]" Then
260 If Mid(strRmveBBCode, posBBCodeTagSrch - 1, 1) = "]" Then GoTo NxtCSSPosPos ' If we hit another ] then start again to see if is a valid BB code start section
270 Dim BcrdSEnd As Long: Let BcrdSEnd = posBBCodeTagSrch 'Position of possible Start Code Tag End
280 Dim LTagStLoop As Long 'Last loop to find start of start Code Tag
290 For LTagStLoop = posBBCodeTagSrch - 1 To 1 Step -1 '_- Second inner loop___________________________
300 If Mid(strRmveBBCode, LTagStLoop, 1) = "[" Then
310 Dim BcrdSSt As Long 'Have to put it here, - I may occaisionally have to set it to 0 in next line
320 If Mid(strRmveBBCode, LTagStLoop + 1, 1) = "/" Then Let BcrdEEnd = BcrdSEnd: Let BcrdSEnd = 0: Let BcrdESt = LTagStLoop: Let BcrdSSt = 0: Let posBBCodeTagSrch = LTagStLoop: GoTo NxtCSSPosPos ' Found a second end Code Tag. So change the previous found start and stop , and adjust the Loop Bound variable Count appropriately for a new search for a start Code Tag
330 Let BcrdSSt = LTagStLoop
340 Let posCurrent = BcrdSSt 'End of Code Tag section search
350 GoTo FkOffCrd ' We leave this For the start Code Tag Start Search and go to Fuk Off Crd:
360 Else ' Still looking for start of start Code Tag
370 End If
380 Next LTagStLoop '_- Second inner loop________________________________________________________________
390 If LTagStLoop = 1 Then GoTo TheEnd 'Case we found a start start [ at 1 or failed to find a start start [ for the complete possible Code Tag section search
400 Else 'Not found end of start Tag or start of start Tag
410 End If
420 NxtCSSPosPos: Next posBBCodeTagSrch ' go back in possible BB code string'_-Loop for Pos tag pair section-----------------
-
Code part 4 of 4 parts
Code part 4 of 4 parts
Code:
430 FkOffCrd: Rem 3) "I think we come here with a complete set of 4 positions"
440 If BcrdEEnd <> 0 And BcrdESt <> 0 And BcrdSEnd <> 0 And BcrdSSt <> 0 Then 'Just to check'
450 Dim SttBcrd As String, StpBcrd As String ' Start and stop tags
460 Let SttBcrd = Mid(strRmveBBCode, BcrdSSt, BcrdSEnd - BcrdSSt + 1): Let StpBcrd = Mid(strRmveBBCode, BcrdESt, BcrdEEnd - BcrdESt + 1)
470 Dim SttWrd As String, StpWrd As String ' like |Color=Red|, |/Color|
480 Let StpWrd = Mid(StpBcrd, 3, Len(StpBcrd) - 3) ' like Color from |/Color| - Whole Word, from 3rd Chr , for Length as WholeWord-3
490 Let SttWrd = Mid(SttBcrd, 2, Len(StpWrd)) ' like Color from |Color=Red|
500 If UCase(SttWrd) = UCase(StpWrd) And Mid(StpBcrd, 2, 1) = "/" Then 'Ucase allows for differences in cases And Mid(SttBcrd, Len(SttWrd) + 2, 1) = "=" Then
510 Let strRmveBBCode = Replace(strRmveBBCode, SttBcrd, "", 1, 1) ' Replace in ( strRmveBBCode , the start tag , with no string , start loooking from and return from character 1 )
515 Let strRmveBBCode = Replace(strRmveBBCode, StpBcrd, "", 1, 1)
520 Else 'No shortening of string foe invalid tag word
530 End If
540 Else ' no last ] of a possible Code section yet, so keep going back down in the main string
550 End If
560 Else
570 End If
580 Next posCurrent '_-===Main Loop========================================================================================
'590 TheEnd:
600 MsgBox prompt:="" & strRmveBBCode & "": Debug.Print "" & strRmveBBCode & "" 'Hit Ctrl+g when in VB Editor Window, reveal Immediate window after code run
Dim RapedText As String: Let RapedText = strRmveBBCode ' TextWithBBCodeEnit with BB Code Code tags removed
Rem 9) This a Another Object from class to be sure we have the data in the Clipboard
'Dim objDat As DataObject
'Set objDat = New DataObject 'Set to a new Instance ( Blue Print ) of dataobject
Dim objDat As Object
Set objDat = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
'9b) Put in (and Get back from clipboard) the raped text.
objDat.SetText Text:=RapedText 'Make Data object's text equal to original text without the BB Code Code Tags
objDat.PutInClipboard 'Place current Data object into the Clipboard
objDat.GetFromClipboard 'All that is in the Clipboard goes in this Data Object second instance of the Class.
Dim TxtOut As String: Let TxtOut = objDat.GetText() 'retrieve the text in this second instance of the Class. ( In this case all in it is the text and possibly vbCr and vbLf )
MsgBox prompt:="You dumped in Clipboard this " & vbCr & RapedText & vbCr & "and if you try to get it, you should get" & vbCr & TxtOut & ""
Rem 10a) Code Part 3) Belt and braces check. A check is then done finally to see if the two raped from tags strings are the same
If NewWordText <> RapedText Then MsgBox prompt:="Text from Word Dialogue Box Find Replace Wild card way, and " & vbCrLf & "Long String manipulation way are not the same. Oh dear"
'10b) Tidy up.
TheEnd: ' ( Come here always, even on a unpredictable error ) or i wouod If i had an error Handler, Lol.
Set objDat = Nothing ' Good practice... maybe....
Set objCliTextCopied = Nothing ' ....... http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring.html#post4414065
End Sub
-
One problem noted in the previous codes was that the case of nested BB Code tag pairs, the codes did not work. At many forums such nesting of this form is permitted in BB codes.
[color=Green]Comments [color=Red]Highlight[/color] Comments[/color]
The returned result is
Comments Highlight Comments
None of the codes discussed so far will work for such a case.
Should the Code tag type be dissimilar, such as_..
[CENTER][B]Title[/B][/CENTER]
_..then at least the Find Replace Wildcard Code will work for that by virtue of matching in the String first, for example, in the above example, _..
__ CENTER __ __ __ __ CENTER __
_.. then
__ B __ __ __ __ B __
However my Long string manipulation code will not even work for that.
I have done a Long string manipulation code to be discussed in this and the following posts which , I think, work for all situations.
Brief Descriptions is:
The entire string is held in a variable, strBBCode. This is declared in a Subroutine. Something similar to that was done for the last code )
change 1) Minor to last code:
Unlike the previous codes, ( which sequentially removed BB Code code tags ( by replacing with "" )), the code tags are replaced by some arbitrary character ( This is simply chosen as any not likely to be used as text in the main initial string https://www.mrexcel.com/forum/excel-...ml#post4214083 )
change 2) Minor
This itself is not such a major change in the code format, but it facilitates the main change, 3) below. This change is that bulk of the code is within a Function, (Function LongWayOfDoingIt2ReCurseCyClops(__ ) . It is "Called" and needs to be given_..
_.. the string, strBBCode, By Referral to that variable, rather than its By its Value contents
and_..
_.. a Value for the current character position, which initially will be the end ( or length in characters ) position of strBBCode.
But those are not the main changed characteristic to the code.
To recap: All my long string manipulation codes, including this Function, have the general characteristic that they loop backwards in the complete string until a ] is found. An attempt is made then to find a [/ . Once this is found an attempt is made to find a ] and then a [ .
At this point a possible code pair requirement , looking backwards, of ] [/ ] [ is achieved
( Reversing that to the correct order shows that clearly more clearly,
[ _ ] __ [/ _ ],
or
[codeText] AnyText [/CodeText] .
Or
[Color=red] AnyText [/color]
_.. etc...)
Having found a code tag pair, a check is made for its validity ( the same matching work, such as, codetext, color, for example ) , before the adjustments are made to the main string. After that , the code then moves on and steps further "back" in search of another pair_..
_.. But just before it does that check, all codes, including this new Function, at the last found [ , do a check to see if in fact the next character after the last found [ is a / , indicating that in fact the assumed start tag, [codeText], was in fact another end tag, [/Codetext_b]. Action is then taken should that be the case.
At this point the codes are very different. The action taken is different
In the previous code, it was assumed that in such an event, the first found "end tag" was a rouge text looking like an end tag , but invalid, and not matched to a start code tag. The first found "end tag" was then ignored, and another search made for a matching start tag to the second found end tag.
This results in an error situation for a valid nested BB Code tags situations.
The new code works therefore much differently.
Main change 3):
In the new code, this point is around lines
[U] [I][color=Green]430
-
Final usage of Function
Initial code to Call the Function for the first time. ( The function may Call itself one or more times further )
The Function will not run itself.
It needs to be Called with the initial parameters passed, the main string, strBBCode, along initially with the length of that string as the start point from which to step back.
A routine is needed for that.
Additionally, once the initial Function run , ( which is set off by this routine ) is finished, we will have the original string, strBBCode , returned in a modified form with the replacement character in place of all found code tags. These need to be removed, which can be easily achieved by replacing them with zero length strings.
An example code is given in the next post.
Example Code:
[code]'10 '
Sub TestsBBCodeString() '
20 '
30 Rem 2 Bits needed as Part of Solution
40 '2a) String will need to be got. The variable for it is referred to by changes in any Functions used. The initial length is effectively just the current position stepping back through the total character string
50 [color=green]' Some variables: So A variable in VBA is like the Link to the part of proxy site where a few things about the actual Final site is informed about. Tiny is the pointer. Amongst other things it has a link to actually where all the stuff is. Like Dim Str As String means at Str will be stuff like how long the text in that string is as well as a link to the memory where the whole string actually is. So that is like more efficient if you want to get at the length
-
Recursion Function to remove BB Code code tags, described in last two posts
Recursion Function to remove BB Code code tags, described in last two posts
Code:
'140 '
Public Function LongWayOfDoingIt2ReCurseCyClops(ByRef strBBCode As String, ByVal BkStt As Long) As String ' I do not actually need any As ______ as nothing is returned, but you never know a string to retuen might be useful later
150 Dim vTemp As Variant ' For Debugs
160 '
170 Rem 1) Main Loop for finding BB code pair String=====================================
180 Dim StpBk As Long
190 For StpBk = BkStt To 1 Step -1 ' Looking for the first ] likely at end of end tag.
200 Let vTemp = Mid(strBBCode, StpBk, 1)
210 If Mid(strBBCode, StpBk, 1) = "]" Then ' we note Position and need to look for a [/ On a recursion call this conditiuon is always met
220 Dim BcrdEEnd As Long: Let BcrdEEnd = StpBk ' Position of possible End Code Tag End
230 Dim posBBCodeTagSrch As Long ' For search through possible valid BBCode Section'_-Loop for Pos tag pair section--
240 For posBBCodeTagSrch = StpBk To 2 Step -1
250 If Mid(strBBCode, posBBCodeTagSrch, 1) = "]" Then Let BcrdEEnd = posBBCodeTagSrch: GoTo NxtCESPosPos ' If we hit another ] then change the stop tag stop character position and start again to see if is a valid BB code section
260 If Mid(strBBCode, posBBCodeTagSrch, 2) = "[/" Then ' Found a stop tag "[/" at posBBCodeTagSrch, so mark..
270 Dim BcrdESt As Long: Let BcrdESt = posBBCodeTagSrch ' ..Position of End Code Tag Start and ..
280 Exit For ' we have an end code tag from a possibly code tag pair section
290 Else 'No luck finding a "[/" start bit of stop tag yet so keep looking Matey
300 End If
310 NxtCESPosPos: Next posBBCodeTagSrch ' trying to find a start [/ pair further back keep looking Matey
320 If posBBCodeTagSrch = 3 Then Exit Function 'case we never found the start of an End Code Tag
330 ' Loop likely at end of start tag ]
340 For posBBCodeTagSrch = BcrdESt - 1 To 1 Step -1 ' Looping furhter back to find a "]" likely of a start code tag but possibly a nested stop tag
350 If Mid(strBBCode, posBBCodeTagSrch, 1) = "]" Then ' possible start from back of "]" likely of a start code tag but possibly a nested stop tag found so....
360 If Mid(strBBCode, posBBCodeTagSrch - 1, 1) = "]" Then GoTo NxtCSSPosPos ' we have a second "]" one back, looking back so this will be caught by next back 1
370 Dim BcrdSEnd As Long: Let BcrdSEnd = posBBCodeTagSrch ' Position of possible Start Code Tag End
380 Dim LTagStLoop As Long ' _- Most Innerloop to find start of start Code Tag
390 For LTagStLoop = posBBCodeTagSrch - 1 To 1 Step -1 ' _- Most inner loop [ likely start of start tag_
400 If Mid(strBBCode, LTagStLoop, 1) = "[" Then
410 Dim BcrdSSt: Let BcrdSSt = LTagStLoop
420 Rem If [/ Then Oh dear time for a "recursion wonk"
430 If Mid(strBBCode, LTagStLoop, 2) = "[/" Then 'Seems like our last attempt at finding a start tag caught a nested end tag
440 'Time to freeze this Function with current end tag info.
450 Call LongWayOfDoingIt2ReCurseCyClops(strBBCode, BcrdSEnd) ' Position of possible Start Code Tag End is actually another end tag end, so give this ] position as the start position and run another copy of the Function. At the start of which the first check should catch the ] and redo the finf´ding of the last tag complete so is a bit ineffecient
460 'Time to unfreeze this Function, and continue where left off having now possibly modified the main string for one or more nested tag pairs, as well as probably catching all but the possible pair that I froze on
470 Let posBBCodeTagSrch = LTagStLoop ' When we went off to the copy of the function our LTagStLoop was at the start of what turned out to be a nested end code tag. That is as good a place as any to strt going further back now to try to find the match for the end tag before the nested one. We will be going throught the lkast nested one, but never mind
480 GoTo NxtCSSPosPos ' unfreeze search for a matching start tag
490 Else ' As soon as we come here we are likely
500 End If ' ready to do the string modification for a found matching pair
510 Let StpBk = BcrdSSt ' - 1 will be done at Next StpBk 'End of Code Tag section search ' I am commiting the cardinal sin of changing the Loop bound variable caount in the main outer step back in character Loop
520 GoTo FkOffCrd ' We leave this For the start Code Tag Start Search and go to Fuk Off Crd:
530 Else
540 End If
550 Next LTagStLoop ' _- End Most inner loop [ likely start of start tag_
560 If LTagStLoop = 1 Then GoTo TheEnd 'I think here we must always be at LTagStLoop = 1 - Case I think we failed to find a start start [ for the complete possible Code Tag section search
570 Else ' Not found a "]" likely of a start code tag but possibly a nested stop tag found
580 End If
590 NxtCSSPosPos: Next posBBCodeTagSrch ' End Loop likely end of start tag ]
600 If posBBCodeTagSrch = 0 Then GoTo TheEnd ' For any outer search failed to find a ] at all or a search for matching start tag that was fruitless
610 FkOffCrd: Rem 3) "I think we come here with a complete set of 4 positions"
620 If BcrdEEnd <> 0 And BcrdESt <> 0 And BcrdSEnd <> 0 And BcrdSSt <> 0 Then 'Just to check'
630 Dim SttBcrd As String, StpBcrd As String ' Start and stop tags as complete strings including [ and ]
640 Dim LenSttBcrd As Long, LenStpBcrd As Long ' Some extra variables for clarity
650 Let LenSttBcrd = BcrdSEnd - BcrdSSt + 1: Let LenStpBcrd = BcrdEEnd - BcrdESt + 1 ' As taypical to get length of anything when start and stop positions are known.. -- (stoppos-startpos+1)
660 Let SttBcrd = Mid(strBBCode, BcrdSSt, LenSttBcrd) ' In String , part from [ , for length (stoppos-startpos+1) ' like |Color=Red| or |b|
670 Let StpBcrd = Mid(strBBCode, BcrdESt, LenStpBcrd) ' like |/Color| |/b|
680 Dim SttWrd As String, StpWrd As String
690 Let StpWrd = Mid(StpBcrd, 3, Len(StpBcrd) - 3) ' like Color from |/Color| - Whole Word, from 3rd Chr , for Length as WholeWord-3
700 Let SttWrd = Mid(SttBcrd, 2, Len(StpWrd)) ' like Color from |Color=Red|
710 If StrComp(StpWrd, SttWrd, vbTextCompare) = 0 And Mid(StpBcrd, 2, 1) = "/" Then ' If UCase(SttWrd) = UCase(StpWrd) And Mid(StpBcrd, 2, 1) = "/" Then 'Ucase allows for differences in cases
720 Mid(strBBCode, BcrdSSt, LenSttBcrd) = String(LenSttBcrd, "|") ' Mid can be used to put in strBBCode , starting from start of tag , for a length space within of the tag = any symbol as many times as that length space
730 Mid(strBBCode, BcrdESt, LenStpBcrd) = String(LenStpBcrd, "|")
740 Else ' ' No manipulationn of string for non matching tag word
750 End If
760 Else 'No manipulation of string for not all 4 [ and ] found. Not sure if I ever come here..
770 End If
780 Else ' Case no "]" found in main strBBCode
790 End If
800 Next StpBk ' Stepping further back in Main Loop for finding first "]"============
810 TheEnd:
820 ' Let LongWayOfDoingIt2ReCurseCyClops = "Return from Function after running" ' Option if I wanted to give a value to be returned from Function. By virtue of the ByRef at signature line I effectively continually apply changes to the variable strBBCode
End Function
-
Recursion. A simple Layman explanation. Alternative additional General explanation
Recursion. A simple Layman explanation
General idea, considering parallel to real life:
Where you work there is a Filing cabinet containing the master copy of a sets of instructions for particular jobs (work sequences). These are your written code routines, ( Sub routines and Functions ).
( These job sequences involves you walking around the company and taking out various actions / tasks in different places ). In general you can only follow one set of instructions at a time. But you can stop them before you are finished, or pause them, and follow a different set of instructions.
Think of those master copies as the routines you write and “see” in the VBA Editor code window. A code module is pseudo a draw in the Filing cabinet.
( ***The analogy falls down a bit when considering recursion due to a poor realisation in the debug step mode ( F8 ) code facility, but this might change due to some changes I have suggested at various Microsoft suggestion giving platforms )
Case 1) The normal working case ( no recursion ). Simple single routine code.
Your boss makes a copy of a set of instructions. He gives them to you. You carry them out. That is your job: You do what the boss says, or rather you follow the written instructions given to you at any time by the boss. Whenever you are given a set of job instructions by the boss, you carry them out, starting from when you are given the instructions. In general you can only do one job ( sequence of instructions ) at a time. In general you are waiting to receive your instructions.
Excel VBA is like the worker. Your worker. You are the boss. If you present Excel VBA with a set of instructions ( a written code in a routine ) , then Excel VBA carries them out. It carries them out from the point of the start line. ( like Sub MyRoutine() etc.. )
In general , Excel is waiting to get , or not doing anything but listening out for, instructions. Something must be done to initiate the initial code run.
In general, at least for our discussions here , VBA can only carry out one routine at a time. But it can stop or pause a routine before it is finished and start another one... that is what happens when other routines are “call”ed from within a routine... as discussed in the next sections:
Case 2) A simple routine call from within a routine
You are doing a set of instructions given to you by the boss.
VBA is in a running routine., following the routine, ( code ), instructions.
The boss gives you a new set of different instructions.
Whilst running a routine, VBA hits a code line which calls another routine or uses, ( calls ) , a routine.
You obey. You stop what you are doing, “freeze” any actions in process, and follow the new set of instructions.
VBA obeys. It stops ( freezes or pauses ) the running of the routine ( code instruction copy ) it was doing, and carries out the new ( code ) instructions.
When you have done all the new instructions, you go back and finish the first job that you were doing, starting where you left off, “unfreezing” any actions stopped when you started the second set of instructions..
When the called routine or function is finished, VBA goes back to the first routine carrying on where it left off. Any variables that may have been “filled” before in the first routine are still there, unfrozen now, with the values previously with which they were filled with.
For the last two simple cases, the Debugging ( F8 ) step mode avaialble in code progression can be helpful to demo what is going on.
It is worth noting that what actually is going on is a bit different:
What actually happens can be thought of as closer to something of this form:
The codes you write are master copies. When a routine begins a copy of that master, including all provisions necessary for a full set of any variables used is made. Once the routine ends, this copy and all variables are erased. ( The analogy to real life: For each start of a job sequence, a copy is made of the master instructions, and this is followed. It is thrown away when the job sequence is completed)
If you step through a code in F8 step mode, the VB Editor will show you progression through the master code copies which you wrote and “see” in the VB Editor code window. That is not what is actually happening. But it is fine to imagine that the originals are the actual copies that are being gone through.
It is worth bearing in mind that copies are made and gone through rather than your written masters. That helps to understand, or rather, helps avoid confusion, when considering the next situation, recursion***
Case 3) Recursion. A routine calls itself
This is not a great deal different from the last case. The word recursion is used to cover the situation of a re occurrence of the same set of instructions or procedure, at a point in code running before the previous instructions or procedure was finished. ( In real life analogy: you are given the same set of instructions written on a new copy before you have finished and following the first set of instructions. - So you pause at the point you are at and start doing the same job again before you have finished doing the last one already started)
Another slightly closer analogy to the programming case of recursion is the following: Imagine that you are doing a set of given instructions, when one of the instructions tells you to make a new copy of the instructions and follow those. In such a case you do as in the previous case: You obey. You stop what you are doing, “freeze” any actions in process, and follow the new set of instructions. When you have done all the new instructions, you go back and finish the first job that you were doing, starting where you left off, “unfreezing” any actions stopped when you started the second set of instructions...
:rolleyes:
You may remark, quite rightly, that you will never finish, as you will endlessly keep making a new set of instructions and begin following the new instructions. In the simple case described, that will indeed occur, ( at least until the stack of instructions you have “frozen” along with any stack of any filled variables, ( newly created for each copy ), hits some “overfull” or “overflow” limit where you are stacking them).
;)
In the practice you would have in your instructions some clause referring to the start of a new set of instructions of the form like: If ..something... Then do it.
Hopefully you have chosen that clause appropriately such that at some point you will skip the step of starting a new set of instructions. Further, hopefully that should occur often enough such that eventually all copies of the instructions are finished.
We can achieve this recursion situation in VBA in various ways. A couple of examples:
_ one simply has a code line within some routine, say Sub x( , ) of the form Call x( , ),
or
_ for the case of some function, Function y( , ) , a code line within that function can be present of the form Var = y( , )
Once again it would be important to have some clause so as to follow that code line only If .. something.
Typical Example:
A very typical working example of such a code is to take some actions to and / or within all the Folders and Sub Folders within some Main start folder.
For such an example you would have two codes:
_ a simple “normal” routine, which might, for example, ask you for the initial main Folder.
_ a recursion routine. The recursion routine would take in a Folder name or Folder path or Folder As Object.
The routine would initially be called from the first simple routine, which would pass the main Folder.
For the Folder taken in by the recursion routine some action on and/ or within that Folder would be taken. This would generally mean taking some action on each Sub Folder within the Folder given. Typically, the last action would be to call the recursion routine, passing this time not the main Folder, but the current Sub Folder, but only If the Sub Folder itself has at least one Sub Folder.
One needs to carefully think through oneself the result of this. In end effect all Folders within the main Folder will be considered.
http://www.excelforum.com/developmen...directory.html
http://www.excelforum.com/excel-prog...ml#post4316662
http://excelpoweruser.blogspot.de/20...13383708093554
Debug ( F8 ) code progression step mode is a bit misleading:
For the recursion case following code progression in debug step ( F8 ) mode can be confusing. This is because during the recurring process you appear to jump around in the main original master copy of the recursion function.
I would suggest one imagines that the following happens instead.
(I would further suggest, that this may be what a more intelligent and more demonstrative debug Editor in a Visual Basic development environment might be developed to do in the future):
Imagine the initial copy of the recursion Function is how you see it whilst stepping through the code in debug step ( F8 ) mode. So imagine that this is , in fact, the first copy of the routine. ( ***Remember I noted that actually, effectively a copy, unseen by us, is actually gone through by VBA )
But.
Consider that the following happens when you carry out the line where the routine calls itself.
At this point a copy of the full recursion routine text is made. If you like , the code line calls into existence a new copy. This is than pasted into the code window below the current routine.
The debug curser then jumps to the start of this new copy of the routine. That new copy of the routine is then stepped through.
Imagine that any variables declared in the new copy routine are given a slightly different shade of color to those with the same name in the first routine. This would help us to remember that they are different independent variable, which just happen to have the same name. ( VBA does not get confused as it only “sees” the variables in the current running copy of the function. Any previous functions and their variables are “frozen” )
When in stepping through this copy, the end is reached , the copy vanishes from the code window, along with any variable that were created and used in it, and the debug cursor then jumps back to the line after the line which called it into existence.
Effectively we are doing the process described in _2) . But to visualise this correctly we need to make a new copy of a routine code text and step through that when a routine calls itself ( Currently when using step mode ( F8 ) debug, the progression appears to go through the same actual procedure. It is following the same instructions contained in the main Master copy of the instructions, but the actual instructions it is following are written on a new copy of the master set of instructions. Similarly any variables used in this copy run are unique to this copy run and “die” at the end of the copy routine run, at which point the copy of the instructions is thrown away )
Alan
-
Sub GetsathishsusaStarted()
Code for sathishsusa
Post #3
http://www.excelfox.com/forum/showth...0177#post10177
Sub GetsathishsusaStarted()
Code:
Sub GetsathishsusaStarted() ' http://www.excelfox.com/forum/showthread.php/2161-Highlight-Overlap-dates?p=10177#post10177
Rem 1) Worksheets Info
Dim WSt As Worksheet 'EP Dim: For Object variables: Address location to a "pointer". That has all the actual memory locations (addresses) of the various property values , and it holds all the instructions what / how to change them , should that be wanted later. That helps to explain what occurs when passing an Object to a Call ed Function or Sub Routine By Val ue. In such an occurrence, VBA actually passes a copy of the pointer. So that has the effect of when you change things like properties on the local variable , then the changes are reflected in changes in the original object. (The copy pointer instructs how to change those values, at the actual address held in that pointer). That would normally be the sort of thing you would expect from passing by Ref erence. But as that copy pointer "dies" after the called routine ends, then any changes to the Addresses of the Object Properties in the local variable will not be reflected in the original pointer. So you cannot actually change the pointer.)
Set WSt = ThisWorkbook.Worksheets("sheet1") ' 'EP Set: Fill or partially Fill: Setting to a Class will involve the use of an extra New at this code line. I will then have an Object referred to as an instance of a Class. At this point I include information on my Pointer Pigeon hole for a distinct distinguishable usage of an Object of the Class. For the case of something such as a Workbook this instancing has already been done, and in addition some values are filled in specific memory locations which are also held as part of the information in the Pigeon Hole Pointer. We will have a different Pointer for each instance. In most excel versions we already have a few instances of Worksheets. Such instances Objects can be further used., - For this a Dim to the class will be necessary, but the New must be omitted at Set. I can assign as many variables that I wish to the same existing instance
Rem 2) Checked Names info
'2a) Arrays of data, value(Boolean) and employee name
Dim RngChk As Range
Set RngChk = WSt.Range("AS8:AT11")
Dim arrChkEmp() As Variant, arrEmp() As Variant ' A simple one line code is used typically wherby the .Value "string values" Property is used to return the cell value from a Range object. These are contained in an Array of Variant types. These can be assigned in VBA to an array of appropriately declared (Dim ed) Member Element types, Variant in this case.
Let arrChkEmp() = RngChk.Resize(, 1).Value ' AS ' Using Resize ing Property applied to a Range object - the Range object resized to (nochange to rows, change to 1 column) effectively returns the first column as a Range object
Let arrEmp() = RngChk.Offset(0, 1).Resize(, 1).Value ' AT ' Before Resize, Offset Property applied to shift enclosed spreadsheet range (no shift in row direction , 1 column shift to the right)
'2b) Build string and Array of Employes checked as True
'2b)(i)
Dim Cnt As Long ' Loop Bound variable Count ' Long is very simple to handle, - final memory "size" type is known (123.456 and 000.001 have same "size" computer memory ) , and so a Address suggestion can be given for the next line when the variable is filled in. '( Long is a Big whole Number limit (-2,147,483,648 to 2,147,483,647) If you need some sort of validation the value should only be within the range of a Byte/Integer otherwise there's no point using anything but Long.--upon/after 32-bit, Integers (Short) need converted internally anyways, so a Long is actually faster. )
Dim strEmp As String ' ' Prepares "Pointer" to a "Blue Print" (or Form, Questionaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular "Value", or ("Values" for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. A String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quich checks.. But..http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring-2.html#post44116
Let strEmp = "Overlap dates Between " 'Initial string
'2b(ii)
Dim TrueCnt As Long: Let TrueCnt = 0 ' Count of checked as True employees
For Cnt = 1 To UBound(arrChkEmp(), 1) ' For all employee "rows"
Dim arrChkTrueEmp() As String ' I know the type and am looping to fill in so can choose type
If arrChkEmp(Cnt, 1) = True Then ' Box is checked resulting in Boolean True held in Range object of cell - "...I do not know anything about check boxes. :( ... So I look at TRUE or FALSE value in Array of captured valuees from Range("AS8:AS11")
Let strEmp = strEmp & arrEmp(Cnt, 1) & " and " ' ( '2b)(i) ) add checked names to initial string report for output
Let TrueCnt = TrueCnt + 1 ' Increase count of true checked names ...
ReDim Preserve arrChkTrueEmp(1 To TrueCnt) ' ... Increase array size to accomodate another True name
Let arrChkTrueEmp(TrueCnt) = arrEmp(Cnt, 1) ' Fill next space in Array with next checked as True name
Else
End If
Next Cnt
Let strEmp = Left(strEmp, Len(strEmp) - 5) ' omit last " and "
Rem 3) Main Input data
'3a) Full data range as range object
Dim RngDta As Range
Set RngDta = WSt.Range("B21:E26")
'3b)
Dim arrListNms() As Variant, arrFrm() As Variant, arrTo() As Variant, arrOvrLpDts() As Variant
Let arrListNms() = RngDta.Resize(, 1).Value
Let arrFrm() = RngDta.Offset(0, 1).Resize(, 1).Value2
Let arrTo() = RngDta.Offset(0, 2).Resize(, 1).Value2
Let arrOvrLpDts() = RngDta.Offset(0, 3).Resize(, 1).Value ' RngDta.Offset(0, 3).Resize(, 1).Interior.Color = 255
Rem 4) Main Outer Loop ==============Cnt========= Dim StearEmp As Variant
For Cnt = 1 To UBound(arrListNms(), 1) ' Outer Loop is each name in column B 'Each StearEmp In arrChkTrueEmp()
'4a)
Dim NmeMtch As Variant ' For result of attempt to find next name(Cnt) in arrChkTrueEmp()
Let NmeMtch = Application.Match(arrListNms(Cnt, 1), arrChkTrueEmp(), 0)
If Not IsError(NmeMtch) Then ' This is the case we have found a name I want to check against
Dim CntIn As Long
Rem 5) Inner Loop ------------------CntIn--------
For CntIn = 1 To UBound(arrListNms(), 1)
If arrListNms(Cnt, 1) <> arrListNms(CntIn, 1) Then ' To ignore compare employee with himself
Let NmeMtch = Application.Match(arrListNms(CntIn, 1), arrChkTrueEmp(), 0)
If Not IsError(NmeMtch) Then ' This is the case we have found a name I want to check against
' Now is main part of criteria check
If (arrFrm(Cnt, 1) >= arrFrm(CntIn, 1) And arrFrm(Cnt, 1) <= arrTo(CntIn, 1)) Or (arrTo(Cnt, 1) >= arrFrm(CntIn, 1) And arrTo(Cnt, 1) <= arrTo(CntIn, 1)) Then ' main comdition for match
Let arrOvrLpDts(CntIn, 1) = "Overlap"
Else ' Main overlap condition not met
End If
Else ' Case The Employee name was not one that was checked true to check for Holiday overlap
End If
Else ' case of Checked employee is in Employee Names list
End If
Next CntIn '---End Inner Loop ---------
Else ' Case The outer loop for all names was at a name not to be compared - do nothing and go on to next name in column B
End If ' do nothing and go on to next name in column B at next line
Next Cnt ' --End Main Outer loop ============== ' StearEmp
Rem 6) Loop through arrOvrLpDts() Array to add to report string and mark cell
For Cnt = 1 To UBound(arrOvrLpDts(), 1)
If arrOvrLpDts(Cnt, 1) = "Overlap" Then
Let strEmp = strEmp & vbCrLf & arrListNms(Cnt, 1) & " From " & Format(arrFrm(Cnt, 1), "d" & "-" & "mmm" & "-" & "yyyy") & " To " & Format(arrTo(Cnt, 1), "d" & "-" & "mmm" & "-" & "yyyy") & ""
Let RngDta.Offset(0, 3).Resize(, 1).Item(Cnt).Interior.Color = 255
Else
End If
Next Cnt
Rem 7) Message Box output of report string
MsgBox prompt:="" & strEmp & ""
End Sub
-
Arrays are good. You should use them , in my opinion :)
Notes for
http://www.snb-vba.eu/VBA_Arrays_en.html
http://www.excelfox.com/forum/showth...0174#post10174 https://www.excelforum.com/the-water...ml#post4613906
Code:
Sub snbsVarTypeTypeName() ' http://www.snb-vba.eu/VBA_Arrays_en.html http://www.excelfox.com/forum/showthread.php/2157-Re-Defining-multiple-variables-in-VBA?p=10174#post10174 https://www.excelforum.com/the-water-cooler/1174400-would-like-to-know-about-the-forum-experts-gurus-4.html#post4613906
a_sn = Array(1, 2, 3, 4)
a_sp = Split("1,2,3,45", ",")
a_sq = Range("A1:F5") ' defaluts to Range("A1:F5").Value ' .Value Property returns a Field ( Arrray ) of Variant Member Elements
Dim a_st As Shape: x = VarType(a_st) ' 9 ( Object )
Rem 2 VarType Constants https://msdn.microsoft.com/en-us/library/office/gg251422.aspx
Dim VrTpe As Long
'2a) Variant Variables: You can determine how the data in a Variant is treated..
Dim Var As Variant: VrTpe = VarType(Var) ' 0 vbEmpty Uninitialized (default)
Dim VarDef: Let VrTpe = VarType(VarDef) ' 0
Let Range("A25:A26").Value2 = "Some text" ' .Value2 gives you the underlying value of the cell (could be empty, string, error, number (double) or boolean) ' .Value gives you the same as .Value2 except if the cell was formatted as currency or date it gives you a VBA currency (which may truncate decimal places) or VBA date.
Let Var = Range("A25:A26").Text ' "Some text" given to Variant attempts to coerce to a String and will fail if the underlying Variant is not coercable to a String type
Let Range("A26").Value = "Some other text" ' .Value gives you the same as .Value2 except if the cell was formatted as currency or date it gives you a VBA currency (which may truncate decimal places) or VBA date.
Let Var = Range("A25:A26").Text ' The data is invalid, a Null is given to Variant
Let VrTpe = VarType(Var) ' 1 Contains no valid data
Dim arrVar(1 To 1) As Variant
Let VrTpe = VarType(arrVar())
'2b) Normal Variables
Dim Intr As Integer: VrTpe = VarType(Intr) ' 2
Dim Lng As Long: VrTpe = VarType(Lng) ' 3
Dim Sngle As Single: VrTpe = VarType(Sngle) ' 4
Dim Dble As Double: VrTpe = VarType(Dble) ' 5
Dim Str As String: VrTpe = VarType(Str) ' 8
Dim Obj As Object: VrTpe = VarType(Obj) ' 9
VrTpe = VarType(a_sn) ' 8204 = 8192 (array) + 12 (Variant)
VrTpe = VarType(a_sp) ' 8200 = 8192 (array) + 8 (String)
VrTpe = VarType(a_sq) ' 8204 = 8192 (array) + 12 (Variant) ' a_sq defaults to a_sq.Value, or rather the = string refs to cells which returns a a Field ( Arrray ) of Variant Member Elements
VrTpe = VarType(a_st) ' 9 (object)
Dim a_bt(1 To 1) As Byte
Let VrTpe = VarType(a_bt()) ' 8209 = 8192 (array) + 17 (Byte)
Dim Rnga_sq As Range: Set Rnga_sq = Range("A1:F5")
Let VrTpe = VarType(Rnga_sq) ' 8204 = 8192 (array) + 12 (Variant (used only for arrays of Variants)) !!!! VarType interprets a Range as an array. ???????
End Sub
Sub TextValueValue2() ' https://fastexcel.wordpress.com/2011/11/30/text-vs-value-vs-value2-slow-text-and-how-to-avoid-it/ http://stackoverflow.com/questions/17359835/what-is-the-difference-between-text-value-and-value2
Set c = Range("A27")
c.Value = 1198.3
c.NumberFormat = "$#,##0_);($#,##0)"
MsgBox c.Value
MsgBox c.Text
MsgBox c.Value2
End Sub
Sub M_snb()
sn = Array(String(300, "p"), String(700, "p"), Space(500))
Dim v
MsgBox Len(sn(0)) & vbLf & Len(sn(1)) & vbLf & Len(sn(2))
End Sub
Using Excel 2007 32 bit
https://msdn.microsoft.com/en-us/lib.../gg251422.aspx |
|
|
|
|
|
|
|
|
Normal Variable |
0 |
vbEmpty Uninitialized |
|
|
|
|
|
|
Array Variable |
8192 |
Array ( Member elements Empty ) |
|
|
|
|
|
|
Normal Variable |
1 |
If data is invalid, a Null is given to Variant |
|
|
|
|
|
|
Array Variable |
8193 |
Null |
|
|
|
|
|
|
Normal Variable |
2 |
Integer |
|
6 |
Currency |
|
11 |
Boolean |
Array Variable |
8192+2=8194 |
|
|
8198 |
|
|
8203 |
|
Normal Variable |
3 |
Long |
|
7 |
Date |
|
12 |
------- |
Array Variable |
8195 |
|
|
8199 |
|
|
8204 |
Variant (used only for arrays of variants) |
Normal Variable |
4 |
Single |
|
8 |
String |
|
17 |
Byte |
Array Variable |
8196 |
|
|
8200 |
|
|
8146 |
|
Normal Variable |
5 |
Double |
|
9 |
Object |
|
36 |
UserDefined |
Array Variable |
8197 |
|
|
8201 |
|
|
8228 |
|
Normal Variable |
6 |
Currency |
|
|
|
|
|
|
Array Variable |
8198 |
|
|
|
|
|
|
|
Normal Variable |
7 |
Date |
|
|
|
|
|
|
Array Variable |
8199 |
|
|
|
|
|
|
|
Normal Variable |
8 |
String |
|
|
|
|
|
|
Array Variable |
8200 |
|
|
|
|
|
|
|
Normal Variable |
9 |
Object |
|
|
|
|
|
|
Array Variable |
8201 |
|
|
|
|
|
|
|
Normal Variable |
10 |
Error |
|
|
|
|
|
|
Array Variable |
8202 |
|
|
|
|
|
|
|
Normal Variable |
11 |
Boolean |
|
|
|
|
|
|
Array Variable |
8203 |
|
|
|
|
|
|
|
Normal Variable |
12 |
------- |
|
|
|
|
|
|
Array Variable |
8204 |
Variant (used only for arrays of variants) |
|
|
|
|
|
|
Normal Variable |
17 |
Byte |
|
|
|
|
|
|
Array Variable |
8209 |
|
|
|
|
|
|
|
Normal Variable |
36 |
UserDefined |
|
|
|
|
|
|
Array Variable |
8228 |
|
|
|
|
|
|
|
Worksheet: EmptiesVariables
-
1 Attachment(s)
Reply to Willy And Rick, at https://excelribbon.tips.net/T010768_Shortening_ZIP_Codes.html
This is a comment reply I tried to post to Rick Rothstein and Willy Vanhaelen here
https://excelribbon.tips.net/T010768...ZIP_Codes.html
Possibly some text annoyed the Firewall?
( Also posted here https://www.excelforum.com/developme...ml#post4629001
http://www.excelfox.com/forum/showth...0201#post10201
and in this Text File which is also atttatched https://app.box.com/s/oz2oga0ym6bue2kqf8assy8uq8qdod0e )
_.________________________________________________ _______
Hi Rick,
Thanks very much for popping by. It is really great to hear your “take” on these things. I am continually frustrated that Microsoft, for example, do not give precise information about these things. It appears they are not sure themselves. People like you seem to be the best authorities on this.
To some extent it appears anyone may have an opinion, as no definitive documentation or understanding exists.
I am very glad you seem to think the If({1}, ___ ) is OK: I had been a bit nervous about suggesting it to Willy, as I had not seen it before. But it seemed logical based on all that I had learnt from these sort of things so far.
I have followed your arguments below. You explained very well and I follow your logic and reasoning. Thanks for clarifying a few things.
I came to some general conclusions about what is going on with multi value formula / array analysis and Evaluate. I think I am more or less in agreement with your appraisal. It’s great to hear it. Most people just accept what happens and hack out some of these interesting “coercing” as they often refer to them, as a way to ”get” array analysis to work. Most seem to have no idea how their solutions work.
This is my take, and the reasoning to the
If({1}, ___ )
working as an alternative to the
If(Row(),___ )
( Until recently I only used or had seen the If(Row(), ___ ) or Index( ____ , 0, 0 ) )
I possibly see things slightly the other way around, but probably in end effect the same ...
I was thinking that one of the reasoning’s why CSE is needed is the following:
It seems that single breadth things ( single column or single row arrays or ranges ) , as well as a single range reference works very efficiently due to some mechanism involving an effective help matrix the size of a worksheet which for a single cell reference effectively has that value in the entire cells. For a single breadth range, that matrix is filled in the “other” dimension across or down the effective matrix over the “length” of the range, effectively duplicating the values in the range. This all explains why a single reference like =A1 works very quickly, and also why single breadth things work so quickly, and also explains Implicit intersection which results in a single breadth reference like =A1:A4 or =A1:D1 not giving an error in some cells in a worksheet.
http://www.excelfox.com/forum/showth...on-and-VLookUp
The problem comes with a multi dimensional range reference like =A1:B2. That will error in any cell. What is required is to somehow do some Controlled Shifting of these effective matrices before the doing for each value effectively a single Evaluation on Enter. Maybe that is why they chose the key combination of Ctrl + Shift + Enter.
In a way, the CSE could be thought of “removing” the direct default connection to the worksheet which results in =A1 giving a result in any cell ( except A1 of course ) and = A1:A2 giving a result in some cells.
My argument then would be that Evaluate does not necessarily do array analysis as such, - It simply does not need the CSE to stop it from erroring. Further my argument is that for any =A1:B2, the array analyses does take place , the values are there, but it messes up in a single spreadsheet cell without CSE.
( Evaluate(“=A1:B2”) works to return an Array as by default Excel holds, I believe such references as Range objects, which then have the default Property of .Value applied in many cases to return the single value or values in an Array as appropriate. That can be proved by setting Evaluate(“=A1:B2”) to a Range object variable. It will return the Range object. Equating Evaluate(“=A1:B2”) to a Variant will result in it defaulting to a value or array of values. )
Coming back to Evaluate and multi value ( array ) analysis. I think Evaluate just evaluates.
In the case under consideration, the range is “there” such as A1:A10 is there in Left(A1:A10,5). This will not error in Evaluate, as it does in all but rows 1 to 10 in a spreadsheet. But Left( ) is not programmed to return an Array. Possibly this is what you are saying by “not array aware”.
But, as you suggest if you embed that text string function within another function that is “array aware”, you can “trick” Left into giving all its available values. My argument there is that once embedded into function that is programmed to do array analysis, then in most cases *** , the following happens:
Excel will evaluate as long and as far and in the dimensions of any arrays “available” . In the case of If(Row(), __ ) or If({1}, __ ) this will mean for our example that it “does” for over the range A1:A10.
The If(Row(), __ ) I have seen many times, first in a Forum answer you gave.
The If({1}, __ ) I guessed, following those arguments should do the same and it did. I had not seen that before but I expect someone else stumbled over it as well a long time before me.
A few post down I suggested what happens when you do like_...
Evaluate("IF(Row(A1:A11),LEFT(A1:A10,5))")
The same reasoning suggest this will be “done” over A1:A11. The last evaluation returns an error, as expected.
The fact that the code below does not produce errors in a second “column” in the Array is explained as follows. Excel holds a single breadth range reference like A1:A10 , as I suggested above , in an effective help matrix extending across or down the “other” dimension
So the returned Array duplicates the results in the second “column”
In a way it is what happens in CSE type 2 array entry in which you extend the area you select ( before adding your formula and doing CSE ) to a spreadsheet area beyond the range of values you are expecting back.
Code:
Sub ExtendedAcrossSingleBreadthRefPseudoCSEType2Entry() '
Dim Arr() As Variant
Let Arr() = Evaluate("=IF(Row(A1:A10)*Column(A:B),LEFT(A1:A10,5))") ' Run code in Debug, F8 mode, stop at End Sub. - Highlight either Arr - Hit Shift+F9 - OK You will see in Watch window that Arr is a (1 to 10, 1 to 2) array. The "row" values are duplicated across the "columns"
End Sub
https://usefulgyaan.wordpress.com/20...e/#comment-739
https://www.mrexcel.com/forum/excel-...ml#post4375354
_...................................
That is all not a perfect answer, as it does not explain all situations*** such as The T(If(1,____)) stuff _...
https://excelxor.com/2014/09/05/inde.../#comment-2514
_... which recently gave me more hours of frustration than any of your one liners, which I am happy to say I think I mostly understand now.
It was healthy frustration, in that I learned much from you.
Alan
-
VBA Application.InputBox Option HelpFile:= HelpContextID:= (VBA.InputBox helpfile:= , context:=)
This is a solution ( from me ) to this excelforum Thread :
https://www.excelforum.com/excel-new...contextid.html
It is also required in support of this excelfox Thread :
http://www.excelfox.com/forum/showth...utBox-Function
Original Question
Quote:
Originally Posted by
Doc.AElstein
VBA Application.InputBox Option HelpFile:= HelpContextID:=
Hi,
. I am trying to learn and practice with the .InputBox just now.
. I am getting there with most aspects. But I am struggling to find good explanations of, or rather, examples of actually using the two optional arguments Helpfile and HelpContextID
. Can anyone give me or point me in the direction of a working example / examples using specifically these options, with a brief explanation of what is going on
Thanks
Alan
_
A Bump on the question:
Quote:
Originally Posted by
Doc.AElstein
Bump
(
on getting these optional things, HelpFile:= _ , HelpContextID:= , to do what ever it is they are supposed to )
Hi
I am getting clued up on the simpler “Pop up User Info getting / giving Window” stuff currently.
I would like to consider them all at their full potential for a better comparison.
So I could do with having an answer to the question that is the main subject of this Thread.
It is a couple of years along the way now – I had just started with computers back then.
I think I may have a better chance now of understanding the Link given to me in post #2
https://www.excelguru.ca/content.php...r-Applications
It is clearly not straight forward so I had no chance back then of having the slightest idea what that was all about. At first glance I think I might at least be able to make a start now…
I can’t find any other articles or documentation on this, -
If anyone has any input on this, for example a full working example that they are able to walk me through using, then it could probably save me a lot of time.
Otherwise I will see you here again, in a couple of weeks probably, … when I have sussed it out myself.. :)
Thanks
Alan
P.s.
By the way…. I think I will try initially to look at the HelpFile:= _ , HelpContextID:= _ in conjunction with the InputBox Function ( https://msdn.microsoft.com/en-us/vba...utbox-function ) in preference to the Excel Application.InputBox Method ( https://msdn.microsoft.com/en-us/vba...x-method-excel ) because
_a) I am aware now that the Excel Application.InputBox Method has bugs
( The only difference in the working is that the Excel Application.InputBox Method has an extra last optional argument, Type:= . (One “advantage” of this being that for giving Type:=8 will return an object, which will be the range object of the cells either typed in (as an address), or alternatively selected)……I expect this extra complication is what probably screws things up.. )
_b) I believe the InputBox Function is possibly more fundamental, and I am hoping possibly to further my investigations into a ““more direct API route” with this ( https://www.excelforum.com/excel-pro...rary-list.html ) , although it is not clear currently if there is a “more direct API route” for this yet. )
I have also learned and partially myself perfected using string references for referring to range objects as an alternative, and this trend I will be perusing and I expect it to become possibly more trendy to do that. ( It certainly makes code a lot ‘prettier )
Ref
https://stackoverflow.com/questions/...38078#48338078
http://www.mrexcel.com/forum/excel-q...ox-method.html
http://www.vbforums.com/showthread.p...3-but-not-2007
_.______________________________________---
Last answer before final solution
Quote:
Originally Posted by
LJMetzger
You obviously did not drink the Microsoft 'Kool Aid', because its' not a bug, its a feature.
Reply _........
Quote:
Originally Posted by
Doc.AElstein
Lol.. I really should have thought of that “Feature” idea. I keep trying tell people about the special Forum Software “Features” that excelforum has.
I guess you only get this free drug
https://imgur.com/gallery/GjZgOM1 if you are a professional programmer looking to buy some software. I don’t know why but it reminds me of Cresta ( Its Frothy Man
https://www.youtube.com/watch?v=tvo2Hddqg3I ), although as I recall the Cresta that I was hooked on as a Kid was pink in color ). Maybe that has some similar secret hidden ingredient to make you like the providers stuff…
I will have to battle through and get the things to the stand that I conceive without a drugged up mind ( well not on Microsoft’s drug anyway ) as “working”. …. Well, … after a fashion …. I think maybe I have in this case … at least working enough to make the rational decision not to use it…
_._____________________
_..........with Final answer in next two posts:
-
So.
This whole help file business looks like a very complicated way to do something very simple. Not surprisingly it seems to go wrong a lot and fixing it when it breaks needs a lot of computer programming knowledge.
Maybe I should need to word that differently. Hang on, .. __ let me take a quick swig of my Microsoft 'Kool Aid' __ then I will begin.. _...
If I may, just to avoid confusion. I will use the term “Bugg y feature” to refer to what rational thinking says is a Bug and what when drugged up on Microsoft 'Kool Aid' appears as a neat feature.
Microsoft Help Text aka “Help” “Feature” and “Buggery features”
Aka , as applied to this Thread..
What is HelpFile:= HelpContextID:= about
It is impossible for me ( or anyone I expect ) to guarantee to walk you through a working demo of getting the “Pop up” box optional argument parameters of HelpFile:= HelpContextID:= to do what ever it is that they are supposed to do.
The reason for this is that the “Buggering Features” are too many and varied.
Anyway_....Microsoft have a “Help” system, ( Sometimes referred to loosely as “Help” ). Crudely this could be considered as an alternative to writing some explanatory notes in a media such as a text file, or Word document or as in a supplied user manual.
It has the interesting “feature” that in order to master it and use it you will become, or need to be, at a fairly confident level or programming and general computer knowledge. You may need constant access through the internet to get help and advise onto how to maintain the system , that is to say make it continually work, as changes , such as Microsoft updates, will result on additional things needing to be done as time goes on. One of the major “feature” therefore is its Volatility…. And / or it often does not work
A useful tip I have learnt when looking for general information on this Microsoft help through the internet is to include extra terms such as “problem” or “not working”. Without these terms it proved almost impossible to get ay information on the Theme, but with those terms, a great deal of information was obtained allowing for possibility of using up many hours of time in the many interesting actions that may likely to be needed in order to make the Help work, and or repair the damage done to many other things in the initial attempts. These include adding and removing security updates, and manipulating registries and the such both manually and with computer programs calling up many API codes.
Here we go,
Help text Window Feature and “Buggary features”
Most things “Help” or of the help nature in Microsoft uses similar looking Windows. When, for example you is in the VB Editor ( Alt+F11 from Excel spreadsheet ) Window looking at code, you can highlight a word in the code, hit F1, and then such a Help Window comes up
HelpApplicationHelp.JPG : https://imgur.com/ZAXUHmW
So there could be some thinking behind the “Microsoft Help” as a (bad) attempt to bring it all together in some organised way.
.chm Files ( getting them to work/open)
These are the files used as the “raw data” in whatever hidden software takes these files and uses them in some process to get those help windows up. They contain some sort of compressed data of coding written in some variation of the HTML language.
It is likely you may have some .chm files, as the Microsoft Help Text aka “Help” is likely have been used / integrated into some software that you may have on your computer
You may find some ( in Vista and Win 7 ) if you click on the bottom left Microsoft sign and then type in _ chm _ in the small search box.
Here are some also that I made or found earlier https://app.box.com/s/bx2pkvtemsppscz60rd6f430wm89c6fj https://app.box.com/s/varm2k1ojlwwtemnefuhhnym1d84bcxs
It is impossible for me to guarantee to walk you through a working demo of getting the HelpFile:= HelpContextID:= to do what ever it is that they are supposed to do. One of the “Buggering Features” that may prevent getting a successful use of Help is that security updates from Microsoft may intentionally or unintentionally prevent a .chm file from operating as initially intended.
Solutions to this problem range from one extreme to the other.
_ One extreme is major heart surgery to registry files, along with a possible need for application of additional software.
or
_ If you are lucky some of the following may be all you need to ensure that a .chm file will work as it should:
Try out a .chm first( sometimes you need to have done this to make other workarounds work fter you find out that it doesn’t work )
After finding or downloading such a file, navigate to it in its folder , and make a note of its path and file name. ( In the Microsoft Explorer window you may be able to copy the path to the clipboard
chmFolderPath.JPG : https://imgur.com/5Si2HIq )
So for that example shown you need to make a note of the following path and file name ( remember the extra \between the two ) :
G:\Excel0202015Jan2016\ExcelForum\UserForm\samplehelp.chm _ ‘This is the sort of Help File string that you will need
Now try either of the following:
_(i) Double click on the file in the Window Explorer window
or
_(ii) Run this code ( change the Help File string to suit what you have as a .chm File )
Code:
Sub HelpGetItUp()
Application.Help HelpFile:="G:\Excel0202015Jan2016\ExcelForum\UserForm\samplehelp.chm"
End Sub
As a result of doing either of those a Help Window Thingy may or may not come up. If it does come up, it may give an error , that is to say something in the largest window to the effect of one or more things. Here a couple, with workarounds:
Buggery Internet Error Feature 1:
i Navigation to the webpage was canceled.
__ What you can try:
__ .- Retype the address.
Workaround:
If that error is obtained it may mean that some form of blocking has been done by some sort of security measure. If this has happened an extra option will now be seen towards the bottom of the general settings in the Properties Window which you see by right clicking on the file in the Windows Explorer Window and selecting _ Properties
chmUnblock.JPG : https://imgur.com/ObMrbOy
Hit _ Unblock.
After doing this, the (i) or (ii) should result in a normal looking Help type Window.
Note:
_ It may initially be necessary to make the attempt of the (i) or (ii) , or otherwise you may not see the option _ Unblock.
_ Strangely it is sometimes necessary to have done the above workaround in order to avoid other problems later. So it is sometimes advisable to try and get this Buggery Internet Error Feature. One way to achieve this is to upload and then download the .chm file to a trusted file sharing site such as box.net ( https://account.box.com/signup/n/personal#rw1w0 )
Buggery Internet Error Feature 2:
A similar “Internet Error” window may show:
ThisProgramCanNotDisplayTheWebPage.JPG https://imgur.com/NduujoY
i This Program Can Not Display The Web Page
Workaraound: WARNING: Do this at your risk. You are messing with dangerous stuff
via left bottom Microsoft symbol_ regedit.exe_ HKEY_LOCAL_MACHINE
regeditHKEY_LOCAL_MACHINE.JPG https://imgur.com/MHAggqH
_ SOFTWARE --- Microsoft
SOFTWAREMicrosoft.JPG https://imgur.com/n5TnD1b
HTML --- 1.x --- right click mouse _ Neu --- Key
HTMLHelp1_xNewKey.JPG https://imgur.com/z7QnvCV
Name the new folder that appears as _ ItssRestrictions
ItssRestrictions.JPG https://imgur.com/nDyE9tL
right click mouse _ Neu --- DWORD (32-bit) Value
Name the new folder that appears as _ MaxAllowedZone
Double click on that to get an edit Window
EditDWORD32bitValue.JPG https://imgur.com/07AAqu1
Give a value of _ 4
Refresh your computer somehow
(**** Edit: 25Jan 2018: .. another possible Registry modification reported, but have not tried it as have not needed it yet )
3_ Buggery Features 3
See next post for another way to get over the “Help” thing usually not working
_.________________
Back not to the original Thread question:
_ Application.InputBox(Prompt:= , Title:= , Default:= , Left:= , Top:=, HelpFile:= , HelpContextID:= , Type:= ) Method
Coming back to the Theme of this Thread.
As noted , to avoid the extra complication for now of the “Application.InputBox Buggery features” , I am considering a slightly different thing
__ InputBox(Prompt:= , Title:= , Default:= , Left:= , Top:=, HelpFile:= , Context:= )
__( Note the slight syntax difference between Context:= and HelpContextID:= ) Function
One main part of the Thread question ( what are those two options supposed to do ) can now be [Solved]:
Two possible ways to “launch” a .chm help file where discussed ( (i) and (ii) )
A third way (iii) is possible.:- Many of the “Pop up User Info getting / giving Window” stuff have the option to allow a button to “launch such a file” …
Typically the Options are like
The main option:
_ HelpFile:= _________ --- _______ The full path and file name of the .chm file
A second option:
_ HelpContextID:= or Context:= _ --- _A number that takes you to a particular part or section of the main text
_ For InputBox _ it appears the Context:= is not optional.
_ For Applcation.InputBox and for Application.Help _ it appears that HelpContextID:= is optional. (But it is not too clear with the case of Applcation.InputBox due to the additional “ Application.InputBox Buggery features”)
_ For InputBox it appears that no Button for help must be specified: it will appear if HelpFile:= and Context:= are given. ( There is no option to add buttons anyway here )
_ For MsgBox the button option (buttons:=vbMsgBoxHelpButton ) must be given or the Help Button will not appear. ( But if the (buttons:=vbMsgBoxHelpButton is not given and the helpfile:= and context:= are given and valid, then the code line will not error )
_ For Applcation.InputBox it would appear that one of the “Buggery features” is that no Help Button comes up. ( But then..Nothing to do with the Help seems to work for Excel 2007+ with Applcation.InputBox _ – That is a “feature” of it .. “Bugger me feature”
The next post will attempt to make a .chm file. But will also have to tackle possible further “Buggery features”
Ref:=
InputBox ( Prompt:= , title:= , default:= , xpos:= , ypos:= , helpfile:= , context:= ) ) ' If helpfile is provided, context must also be provided. Button comes then automatically.
MsgBox ( prompt:= , buttons:= , title:= , helpfile:= , context:= ) ' If helpfile is provided, context must also be provided . _ For the required Button buttons:=vbMsgBoxHelpButton must be given
Application.InputBox ( Prompt:= , Title:= , Default:= , Left:= , Top:= , HelpFile:= , HelpContextID:= , Type:= ) ' “Buggery Features”: In Excel 2007 + Left:= , Top:= , HelpFile:= , HelpContextID:= can be anything and are ignored
Application.Help HelpFile:= , HelpContextID:= ' , HelpContextID:= is optional
https://stackoverflow.com/questions/...e-was-canceled
https://msdn.microsoft.com/en-us/lib...(v=vs.60).aspx
https://www.youtube.com/watch?v=1gdGpnCCFWM
**** http://www.winfaq.de/faq_html/Conten...?h=tip2026.htm
https://powerspreadsheets.com/excel-vba-inputbox/
-
Create a Help Project. Aka make a .chm file that probably won't work
Part 2 A walkthrough example
Part 2a) Getting a .chm file that might come up by double clicking on it or via Application.Help HelpFile:=MyCodeX.chm
_3_ Buggery Features 3 / Workaround ( To understanding WTF Microsoft HTML Help Workshop is ) :
This is just one way that on average lead to the most success of getting a final working .chm
Instead of starting from scratch, I found I had a better chance of producing a final .chm if I started with one that worked and went backwards.
Unfortunately this is characteristic of many things Microsoft. You need to have a working answer to or a working solution to get there ? A "chicken and egg" situation. So I have done my best to give a working solution on which to build / modify.
In a way I am not really using the Microsoft HTML Help Workshop as it is intended. I guess the Idea is that you can make , edit and organise all the files you need to create a final .chm with the Microsoft HTML Help Workshop Development Environment. Sounds simple but I could not find any decent documentation or learning material. In most of the You tube videos the author seemed confused and surprised half the time as to what was actually going on
To start with you need to have a working .chm.
-
Create a Help Project. Aka make a .chm file that probably won’t work
Part 2 A walkthrough example
Part 2b) Getting a .chm file that might launch from the help argument options in InputBox Function
_4_ Buggery Feature Context-Sensitive Help ( InputBox Function )
A special form Of Cursor Lock:= was used when the Microsoft data base xxxxs developed a few things:
Cursor Lock:= Load of dis coordinated Bollox aka Another mess and it does not work ever not even from the start but don’t tell anyone maybe they won’t notice.
From the last post we see that for _ InputBox Function ' If helpfile:= is given , then context must also be provided. ( This is not the case for Application.Help, - the HelpContextID can be omitted. )
But possibly someone that should have taken that into consideration forgot about or did not know that . Oh dear.
In fact, frequently a problem arises ( not just in the case of the InputBox when calling up a help Window ) : You may get an unexpected error, or rather an error message , something of the form
___ HH_HELP_CONTEXT called without a [MAP] section
HH_HELP_CONTEXTcalledwithoutaMAPsection.JPG https://imgur.com/8NOQW95
( The code may go on further never the less , after hitting OK, or even in some case it will move on whilst the Message box is still showing, but the Help Window you wanted will not be shown.
The following workaround may get around this problem.
Workaround: ( Patch up the .hhp file )
From this point I am not quite sure what it is that I am doing, but it appears that some “directions” are missing. These are necessary to satisfy one of the standard Windows programs ( API ddl stuff: http://www.eileenslounge.com/viewtopic.php?f=18&t=28885 ) which is called into use , for example, by the the context:= argument parameter, which in the case of the InputBox Function is not optional once the helpfile:= is given.
## The main project file ( the file with the .hhp extension ) can be opened with a text editor such as Notepad++. Or at least if you do that something is displayed which you can edit as if it was normal text. What you see there is similar to what you see in the left hand window of the HTML Help Workshop window after you have a created/ compiled project:
One way to get to this is in the Windows File explorer Window select and right click mouse to get the option to Edit with Notepad++
RightClickOnhhpFileOpenWithNotepadPlusPlus.JPG https://imgur.com/7AOgfiQ
By modifying the .hhc project File in Notepad, saving that, and then opening the hhc project file in Microsoft HTML Workshop, and finally compiling will result in the changes reflected in the final .chm file
These following changes, taking the current working example as example will illustrate the added information which appears to add the “missing directions”
Part of the initial File looks something like this, here in this example showing two HTML Files:
Code:
[FILES]
INDEXPAGE.htm
_1X40LL8V5.htm
Somewhere under that must be added something to give finally in place of that above , the following final text shown below
Code:
[FILES]
INDEXPAGE.htm
_1X40LL8V5.htm
[ALIAS]
AnyWord = INDEXPAGE.htm
AnotherF___ingWord = _1X40LL8V5.htm
[MAP]
#define AnotherF___ingWord 2
#define AnyWord 42
After doing this, the file must be opened in Microsoft HTML Help Workshop and compiled to produce a new .chm
Usually then I got success in calling up a help window from a code line including both of the two options
of
HelpFile:=
and
the context:= or HelpContextID:=.
Exactly what is going on there is anyone’s guess, or those that know won’t tell, maybe as they forgot to get the whole thing co coordinated correctly from the start. For some unknown reason a constant variable must first be associated with a File, ( That is the AliAS stuff ), after which a number can be given to that variable.
I got this info from various reported ways to fix various bugs, ( those were not directly related to anything to do with the InputBox Function ), so I expect there are some integrate internal coding reasons for having to do this bodge ( workaround )
Note also interestingly, that in both the case _... of the
_ InputBox __ ‘ including HelpFile:=, and context:=
and the
_ Application.Help __ ‘ including the optional HelpContextID:= argument
_... as long as valid sections are given in the hhc “text” section, then the code will not error if a non existent Context number is given. In this case no help window comes up.
If a valid ( existent ) context number is given then… if you are lucky… it works finally !!!!
_...____
So I got it to work., finally…. :)
I went through worked examples following all the stuff that I have tried to explain in the last few posts..
Then when I run a code like this:
Code:
Sub UpDogsBollox()
' Application.Help HelpFile:="G:\Excel0202015Jan2016\ExcelForum\UserForm\HTML Workshop\chmFillesProjectFiles\Jan21\AnyFileName.chm", HelpContextID:=2
Dim strReturned As String
Let strReturned = InputBox(Prompt:="Hello Help World. Help", Title:="Alan Help", Default:="Bollox", xpos:=100, ypos:=100, HelpFile:="G:\Excel0202015Jan2016\ExcelForum\UserForm\HTML Workshop\chmFillesProjectFiles\Jan21\AnyFileName.chm", Context:=2)
End Sub
This is what happens:
First an InputBox pops up,
and then
if you select the Help Button, ….. then a help Window comes up :)
HelpGetUpBollox.JPG https://imgur.com/KdKOYWr
Conclusions:
I think am happy to mark this thread as [Solved].
I have got as far as making the_..
HelpFile:= HelpContextID:=
( or rather the InputBox Function which works
HelpFile:= Context:= )
_..options in the typical “simple Pop up user interface message box / input box” to work, after a fashion, to do whatever it is that they should do.
What they should do is at least clear now:, ( Obvious to some maybe.. but no documentation says this clearly … ): The typical _ helpfile / context _ optional arguments should cause an extra button to appear which when Hitting should launch a Window which is part of the “integrated Microsoft Help” thingy.
I have gone where probably not many have in recent years, and that is to get working examples.
I’ve got far enough to realise that the “integrated Microsoft Help” thingy might have been somebody’s career making pet idea for a while and seemed a good idea at the time. In the mean time it is a mess and usually does not work.
It would probably be better to go back to writing notes on the back of a Beer mat
:) ( And don’t bother with the drink Microsoft 'Kool Aid'. – drink something better. I can recommend some good dark German Bier )
[Solved]
Alan
P.s.
( Any comments or further inputs would be very welcome, Thanks )
Ref
https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
https://www.codeguru.com/cpp/w-p/hel...-HTML-Help.htm
https://support.microsoft.com/de-de/...sensitive-help
http://www.help-info.de/en/Help_Info...context-id.htm
Some general notes:
Files:
hhp _ is a project File. The big thing that you usually will want to create as / with _ File --- New _ with HTML Help Workshop or other software. This will somehow contain or at least “manage” somehow the following 3 file types
“data” type files, which are used in
hhc _ is a Help table of contents, usually just 1 I think
hhk _ is a Help index, usually just one I think
htm _ are fairly standard HTML file thingies. If you read any good introduction article, book or watch a good introductory You tube video then you will soon get the general idea
https://www.youtube.com/watch?v=1gLh...D6F7E289625976
These HTML files contain as main part the bulk of all the text and other stuff you actually want to read. If you are lucky then you might find that simply double clicking on them will “bring them up” as normal looking stuff to read. This probably will come up in your internet browser: Most browsers I expect recognise these types of files, and you can also probably get them up manually if you copy the whole string path and file name and then paste it into the URL bar of your browser ( URL Bar = the place where you usually see the long _ https://www.goog………………. _ – In place of that paste in the _ G:\Excel0202015Jan2016\Ex……………\Part2.htm )
Modifying Files:
The hhp file opens in Notepad ++ and shows some text. ## This was useful in order to modify to add those missing [ALIAS] and [MAP] bits
All other files can be opened and modified in a text editor such as Notepad or Notepad ++
Actually making/ modifying a “Project”:
I’m buggered if I could actually work out how to use the HTML Help Workshop Development Window in the efficient way that I expect it should be.
I expect the idea is that you move around and modify the HTML Files and some how do all the index and contents automatically. But god knows how.
This is how I actually got the stuff working…
Way a) manipulate all files with text editors… mostly !!
The hhc and hhk files ( List index contents stuff ) look similar and have to stay similar, at least as far as how the HTML files they reference is concerned.
You open them up with a text editor, preferably both at the same time, and make sure that the HTML Files that they reference exist.
Changehhkhhchtm.JPG https://imgur.com/0gMOk8J
Once you have done that, then you don’t actually have to “load the HTML Files”… when you make a new project… these files, and / or the hhp file and / or the complied .chm “ know where they are and what to do with them.
The HTML Files you then modify manually by opening them up in a text document .. or even in Word it seems possible !!
Default Topic Index Page Title Page
The hhc File and the bit of the hhp File that opens in a Notepad ++ and the left margin window must all reference the same Default topic=, but god knows what that is – it seems to be some HTML file that must also exist
So you need to change 4 things simultaneously,
_ 1 hhc File in a text document
_ 2 the bit of the hhp File that opens in a Notepad ++
_ 3 !! and for this you have to be in the Microsoft HTML Help Workshop Development Environment .. modify the left margin window bit .. Project .. [OPTIONS] …..
_ 4 the name of the HTML file
IndexPage_1_2_3_4.JPG https://imgur.com/ztE5ZES
Way b) In the Microsoft HTML Help Workshop Development Environment
Select either the Contents or Index tab ( to right of the Project tab ) , and double click on the bit you want to modify. The corresponding HTML File comes up the main big window and you can work on it similarly to as if you had opened with a text program such as Notepad or Notepad++
-
VBA to automate Send and Automatically Sending of E-Mails and Workbooks
VBA to automate Send and Automatically Sending of E-Mails and Workbooks.
Learn Material
In support of this Thread
http://www.excelfox.com/forum/showth...kbooks-at-once
Available stuff on the internet
I downloaded about 40 YouTube videos, ( TheElvesAndTheShoemakerAndEmailUsingVBA.JPG : https://imgur.com/rPNV8Kd ) and found an endless amount of Blogs and other technical support and documentation. I doubt it is possible to review all the Blogs and other technical support and documentation as there is just too much.
I narrowed down the You tube tutorials to a list approximately in order of how good I found them.
Its on a scale of 1 to 10 , 1 as very useful and 10 as not very useful. Above 10 gives an approximation of how far away I estimate they are in informing / educating as needed to allow somebody to successfully produce and understand a working code
Here is the current list:
I will update it from time to time
_1 ) Way 1) Use the CDO (Collaboration Data Objects ) object library available in VBA.
_1b ** VBA A2Z : Email Automation using VBA. Use GMAIL, Yahoo, Microsoft etc. : https://www.youtube.com/watch?v=nj8mU3ecwsM
_1a ** Dinesh Kumar Takyar : How to send email using Gmail via Excel VBA : https://www.youtube.com/watch?v=pFl7W8d7d4M
_2a DontFretBrett : Send Email From Excel Using VBA & Gmail : https://www.youtube.com/watch?v=cOhupIT0rNA
_4 ** FREE VBA TIPS : gmail vba automation | smtp error fix - gmail via Excel automation - vbatip#31 : https://www.youtube.com/watch?v=Z4aHONly9UQ
_5 Computergaga : Email Workbook as an Attachment - Excel VBA- : https://www.youtube.com/watch?v=ibjNwZqOZnY
_6 GuideMe ShowMy Testie : How to send an automated email using VBScript : https://www.youtube.com/watch?v=H4nnPxnCIbI
_7 Office Academy : Send Email from Gmail using Excel VBA- Modified (with Code Explanation) https://www.youtube.com/watch?v=KIH_FjpPZyg
_8 FREE VBA TIPS How to send email using gmail via Excel VBA _ 100% working _ sample attached - vbatip#30 https://www.youtube.com/watch?v=cJ3tQTjRTHM
_10 Excel VBA Excel VBA _ Total Automation of Sending eMails https://www.youtube.com/watch?v=xGFI3H60yXY&t=9s
Note these ** give details about the security settings required in gmail
gmail security settings
For the purposes of my Excel VBA Email investigations I use two Email accounts: My main German Telekom ( t-online.de ) account. I had no problems with this and more or less everything worked the first time.
I also made specifically a gmail account. I wanted to start from scratch with this to investigate the reported typical security issues that typically seem to prevent the codes initially working. I report my experience with these issues here:
Gmail account code testing
The Way 1), using the CDO object library , was completed and was working successfully with my main German Telekom ( t-online.de ) account.
The I made an account, ExcelVBAExp@gmail.com ( https://support.google.com/mail/answer/56256?hl=en https://accounts.google.com/SignUp ) . The confirmed account was then given as
___ excelvbaexp@gmail.com
I edited code such:
_ changed the username to __ excelvbaexp@gmail.com
_ changed the password to that I had given and confirmed when setting up the account
_ changed the server name to __ smtp.gmail.com
_ used the user server port of 465 ( for my Telekom addressee 456 or 25 seemed to be OK )
_ changed _ .To = Doc.AElstein@t-online.de _ to _ .To = excelvbaexp@gmail.com
I ran code _ Sub PetrasDailyProWay1_COM_Way() _ and it worked first time!!
Here were some of my settings:
excelvbaexpInitialSettings.JPG https://imgur.com/NkvDbvB
LoggedInMy 1 Account 2 SignInSecurity LessSecureApps 3 ON.JPG https://imgur.com/IZEHuGs
I changed the setting from the last screenshot to less Secure Apps OFF. I then got this error when running code code _ Sub PetrasDailyProWay1_COM_Way()
Runtime Error 2147220975 (80040211) LessSecureAppsOFF.JPG : https://imgur.com/ddmNJ2E
Code:
Laufzeitfehler '-2147220975 (80040211)':
Die Nachricht konnte nicht an den SMTP-Server gesendet werden. Der Transportfehlercode lautet 0x80040217. Die Serverantwort lautet not available
Runtime Error '-2147220975 (80040211)':
The message could not be sent to the SMTP server. The transport error code is 0x80040217. The server response is not available
After switching back to Less Secure Apps ON , the code worked.
LessSecureAppsONfrommWarning.JPG : https://imgur.com/TW2Z7XQ
LessSecureAppsONfromWarning2.JPG https://imgur.com/TW2Z7XQ
Note: I had to refresh and log in , Log out etc.. a few times, before it let me slide the switch to ON
_2 ) Way 2)
Office Software.. one of ‘em
Microsoft Outlook …….
I currently do not think it is possible to use this for a “stand alone” way to use Excel VBA to automate Email activity. This is reflected in no rating under 10 or anywhere near. This is not necessarily reflecting the quality of the videos. This is simply my estimation of how relevant they are to a “stand alone” way to use Excel VBA to automate Email activity. I guess I might think differently if I were more familiar with actually using the Outlook software alone for personal management and Emails etc..
40 Wise Owl Excel VBA Introduction Part 29.1 Creating Outlook Emails https://www.youtube.com/watch?v=f8s-jY9y220&t=1813s
129 How to send Email through Outlook at Specific Tme https://www.youtube.com/watch?v=Oa4uDulciQ0
140 Jie Jenn Send Email From Outlook In Excel _ Excel VBA Tutorial https://www.youtube.com/watch?v=3m2THsOZWjg
154 YourProgrammingNetwork Excel 2010 VBA Tutorial 61 Sending Emails https://www.youtube.com/watch?v=iuLb3glfZdk
156 YourProgrammingNetwork Excel 2010 VBA Tutorial 62 - Sending Emails with attachements https://www.youtube.com/watch?v=mOjxfCNnu-U
158 Excel # 348 Serienmail mit mehreren Anhängen über Outlook versenden VBA https://www.youtube.com/watch?v=i-gvQQ0749Y
159 Dr. Gerard Verschuuren Outlook API VBA Can Send Emails from Excel through Outlook or Shell https://www.youtube.com/watch?v=UTzq6-UrmP8&t=10s
160 Send E Mail in VBA Excel through Microsoft Outlook (Video 1 of 4) https://www.youtube.com/watch?v=OwLgf7jebAs
162 Alex C Send Mass E Mail to Distribution List with Outlook and Excel (Video 2 of 4) https://www.youtube.com/watch?v=i_uJNMJVW1k
163 Alex C Send Personalized Mass E Mail to Distrubiton List with Outlook and Excel (Video 3 of 4) https://www.youtube.com/watch?v=sIQLedQPrPs
164 Send Outlook E mail from VBA Excel with HTML Tags (Video 4 of 4) https://www.youtube.com/watch?v=wuoV47SQeKU
171 Excel macro to send bulk emails using Outlook https://www.youtube.com/watch?v=uW8gjf3lB88
190 Excel VBA _ Total Automation of Sending eMails https://www.youtube.com/watch?v=xGFI3H60yXY
255 Send an outlook email with attachments via vbscript https://www.youtube.com/watch?v=nmr283CD_-M&t=93s
260 Excel Macro to Send Email from Outlook with attachment https://www.youtube.com/watch?v=7gy2oRQdGf0
386 Send Invoice as an Email Attachment VBA https://www.youtube.com/watch?v=QsmWVSIW77Y
403 Using Dates with Excel VBA to Automate Email Reminders https://www.youtube.com/watch?v=x2_y0_KDaN0
409 Send email from excel using VBA w3 https://www.youtube.com/watch?v=V3Uc38y4
430 SparksEdge ToExcel SparksEdge_ How to send an Emails using Excel and VBA https://www.youtube.com/watch?v=5hJbSngqpP8
445 Kiran Manchekar Send email using excel macro VBA Tutorial https://www.youtube.com/watch?v=GVopzYXsnqY
700 Jie Jenn How to automatically CC people when you send an email _Outlook Tutorial https://www.youtube.com/watch?v=BGMcsQ89JUk
_._______________________________
Videos from Dinesh Kumar Takyar
CDO way
4 Dinesh Kumar Takyar Aug 28, 2014 CDO How to send email using Gmail via Excel VBA https://www.youtube.com/watch?v=pFl7W8d7d4M&t=16s
Excel VBA – Outlook way
4 Dinesh Kumar Takyar Nov 16, 2012 How to use automation to send ms outlook mail using Excel VBA https://www.youtube.com/watch?v=XSR4gmBuqiE&t=161s
5 Dinesh Kumar Takyar Nov 21, 2014 Automate Excel To PDF & Send PDF Document As Mail Attachment https://www.youtube.com/watch?v=XEBr12uxG2I&t=105s
7 Dinesh Kumar Takyar Jul 3, 2014 Automatically send email to users queries in Excel with VBA https://www.youtube.com/watch?v=N1DMPct5cVA&t=214s
11 Dinesh Kumar Takyar Apr 28, 2014 How to send email reminder automatically from Excel Worksheet using VBA https://www.youtube.com/watch?v=Em4RCvsAV7s
9 Dinesh Kumar Takyar Feb 23, 2018 How to send Email through Outlook at Specific Tme https://www.youtube.com/watch?v=Oa4u...ature=youtu.be
12 Dinesh Kumar Takyar Oct 1, 2014 Using Dates with Excel VBA to Automate Email Reminders https://www.youtube.com/watch?v=x2_y0_KDaN0&t=19s
_.________________________________________________ ______________________-
Here are some other YouTube Videos were some information may be gleaned, but I have not fully reviewed them. They are generally not so useful as the previous ones.
Email Worksheet Via Outlook in Excel _ Excel VBA Tutorial-2jrA-IscKq4
How to Email Your Current Workbook in Excel VBA-0xnk-kjbrpo
Out API VBA Can Send Emails from Excel through Outlook or Shell-UTzq6-UrmP8
Automated email report of excel data-5miDjW6pp5c
Automatically Display Worksheets of Specific User-FPJBVa5i8ec
how to send email in outlook _ vba-i-USyj-iPnY
send birthday emails in powerpoint using VBA-1jFJ35ZPR_A
Serien-Email mit Access, VBA und Outlook versenden-LfDUie6Mlzg
VBA How send email in Access-c41EJLd7HOQ
VBA macro to send a email to one of a list of emails-A-SWhq4GJs4
-
5 Attachment(s)
German Telecom ( Deutsch Telekom FreeMail t-online.de ) Copy Paste HTML code work around
German Telecom ( Deutsch Telekom ( Freemail t-online.de ) ) Copy Paste HTML code work around
I had a problem for a long time when copying manually via the clipboard from Microsoft Word ( or from most other sources ) into my main Email Internet tab Browser Program , t-online.de ( German Telekom Free mail).
The problem started suddenly, close to the time that some update/ changes were made to the Program a few years ago.
The problem was that usually most formatting was lost, and only simple plain b/w text came into the browser.
Previously, most formatting , such as text color, text fonts , test size etc. were maintained such that the final E mail main body as seen and sent, looked very similar to as the prepared message in the Word document. This maintaining of format was / is still the case when pasting manually into gmail and many other places. ( This conversion to simple b/w is usually only seen when pasting into very simple basic text reply windows which supported no formatting )
Formatedtext.JPG ; https://imgur.com/A9Sq5Y1 PastedInGermanEMail https://imgur.com/CZRH5jj
Attachment 1977Attachment 1978
( Here is the same after pasting into gmail: PastedIn gmail.Jpg https://imgur.com/CzqCJ7y )
I noticed the issue in a different situation, and was able to do a simple workaround that spread some light on the issue.
This post gives the background to the situation.
The next post explains the workaround. ( The workaround by passes pasting into the German Email Reply/Editor Window, but the sent and received Email does not suffer from the problem of loss of formatting ).
The issue in a different situation..- The situation
I answered a Forum question here recently, ( http://www.excelfox.com/forum/showth...kbooks-at-once ), and a spin off was a further insight into the issue.
The thread concerned automating sending of an Email with attachments using ( Excel ) VBA.
The successful solution involved sending directly to any Email the complete protocols, messages, HTML code string etc.. etc.. that any Email program, such as Email Internet tab Browser Program , t-online.de , would in end effect “send” out along the internet. ( The final solution was not dependent on having any Email Program available or open. )
The VBA Program to send Email solution:
It was a completely independent “stand alone” solution: Part of the program “ took in “ the main body / main content of the message, that is to say what a user would normally manually type in and/ or paste in. ( As seen in the above screenshots )
( This main body is what I personally might prepare, for convenience, ( and for purposes of having a back up ) , in a Word document and then copy and paste manually across. That copied across would then be sent , and the Word document is then effectively my back up copy of the sent message )
Supplying the main Email message body to the code:
This main body can be supplied to/ given within the code
either as…….
_ a simple text string, like pseudo __ = “ Hello,” & vbCrLf & “ this is my message. “ __ , which would give a final message received like
Quote:
Hello,
This is my message
That text can also in code typically be supplied in a single String type variable in a typical code part like:
Dim strText As String
_ Let strText = "Hello," & vbCrLf & " this is my message"
Code:
Dim strText As String
_ Let strText = "Hello," & vbCrLf & " this is my message"
or………
_ alternatively it could be given as HTML code supplied similarly in a long string variable. That string variable would contain a long string of all the HTML necessary to create text, table, pictures and all possible formatting. That HTML type code can usually be read by most “internet type” or general computer communication type software such as to be able to show a complete formatted page or pages just as one might see in an internet web site or a large Microsoft Word document containing all sorts of formatting including tables, pictures, etc.. etc.. ( I chose to use this second HTML string giving way). This sort of coding is the most common language, at least up until recent years, in computer communication generally.
( By the way htm, HTML ,XHTML, html are more or less the same – it is all to do with coding which mostly consists of ” tag pairs” made with pointy brackets https://www.youtube.com/watch?v=1gLh...D6F7E289625976 )
Making/ writing the .htm code string
If I was a fluent computer HTML expert then I could just write out the htm equivalent of the message with formatting that I wanted to send by Email. I am not, and I don’t need to be: There are many ways to get the code, such as free converters on the internet which give the code if you paste in what you finally want into a window. ( All software I have tried have not suffered from loosing the format when I paste in to their window )
But something even more convenient is available as standard with Microsoft Word:
A simple practical solution was found to be to take advantage of the possibility of saving a normal Word ( file, normally saved with the extension .docx ) , with a file extension of .htm
SaveAs Word.JPG Save As Word doc to htm.JPG https://imgur.com/h7XFAQX https://imgur.com/vhRE9CC
This somehow saves the document primarily in some version of HTML coding language. ( I have no idea what it normally does with the .docx extension – probably a trade secret ). A small amount of coding was then all that was necessary to convert that .htm file into a single text string of the type required for the Email sending code with the option of supplying the main body in HTML format. ( That coding is a line like, pseudo _ strText = GetTheFileAsATextStreamandReadItAll_ )
HTML is one of the main languages used in internet communication, and most internet browsers and Email programs use this. ( In the case of the first simple test string option, ( = “ Hello,” & vbCrLf & “ this is my message. “ ) , that given text string would probably be converted initially by some software into HTML coding before being further used . ( Hence it is more efficient to use the htm option in the first place )
The long HTML string is rather difficult to “see” in its single string form as it is literally an extremely long sting text with pointy bracket HTML code. To a first approximation, this long string of information forms the bulk of what is actually “sent down the internet line”.
No programmer could ever examine easily such a long string of coding. The coding is therefore organised neatly with things like the _ vbCrLf _ used in simple text strings to give a new line.
Because of this last point, if you open such a HTML file with a simple text editor then you see the coding neatly laid out.
For example, this is a screen shot of a simple Word document, which I made and then saved as .htm:
ProMessageTelekom.JPG : https://imgur.com/zn3BGWj
Attachment 1974
“ProMessageTelekom.docx” : https://app.box.com/s/pumcahipuhjbl59ka7lb3qv8i682kcwc
“ProMessageTelekom.htm” : https://app.box.com/s/vfz0y102bikl9hrka6dlgqyotlrttlpi
If I right click on the .htm File in the explorer window, then I can choose to open this file in a simple text editor , ( rather than by using Word, which may be the default, - but note always: You might find that by default it opens on your Internet browser, - that is because , as noted, that browser software has as its main job reading HTML coding and converting it into the text , pictures, tables etc. that you can “see” )
OpenProMessageHTMLWithTextEditor.JPG : https://imgur.com/4zev9Kv
Attachment 1975
Opening the file in a text editor will give you ( towards the end ) the actual coding relevant specifically to “making” that seen text. The relevant part is in between the “pointy bracket code tag pair” named _ div class=WordSection1 ___ /div __ That section is all that I am interested in: All the other stuff is I expect a lot of stuff specific to a Word Document or maybe even some other complicated stuff. I don’t know
ProMessageHTMLInTextEditor.JPG : https://imgur.com/eTUd17q
Attachment 1976
Last part of HTML code for File “ProMessageTelekom.htm” :
See here:
http://www.excelfox.com/forum/showth...0525#post10525
Using code instead of Email Window to send Email ( with attachments )
The codes for doing this are described from here: http://www.excelfox.com/forum/showth...0518#post10518
The end result is , simplified, as follows:
The .htm file is “sent” by the code along the internet line as a HTML code string
rather than
pasting into the Email Editor and hitting the send button manually
The German Telekom Email Editor / Email Program is not used by this particular code . ( that step is effectively bypassed). So, the issue of the format loss occurring when pasting into the German Telekom Email Editor / Email Program is not present
However: The received Email in German Telekom suffered a similar problem.
Using the same Word file example again:
This was the File used to produce the HTML code string to send
ProMessageTelekom.JPG : https://imgur.com/zn3BGWj
This came on as expected in most places, for example in gmail:
ProMessageArrivedAt gmail UsingCodeToSend.jpg : ProMessageTelekom.JPG : : https://imgur.com/u57kRD7
But.…
.. The same sent to a German Telekom t-onlone.de address came on with a similar format loss problem to that experienced when pasting into the German Telekom Email Editor / Email Program
ProMessageRecievedAT tOnLinede UsingCodeToSend.JPG : https://imgur.com/h4wJVXd
_.______________________
So that this post was in way of an introduction.
In the next post is the bit relevant to the issue with pasting into a German Telekom Email Window..
-
Solution ( work arounds ) to the issue with pasting into a German Telekom Email Window.
.
To recap from last Post….
I had a problem for a long time when copying manually via the clipboard from Microsoft Word ( or from most other sources ) into my main Email Internet tab Browser Program , t-online.de ( German Telekom Free mail).
The problem started suddenly, close to the time that some update/ changes were made to the Program a few years ago.
The problem was that usually most formatting was lost, and only simple plain b/w text came into the browser.
Previously, most formatting , such as text color, text fonts , test size etc. were maintained such that the final E mail main body as seen and sent, looked very similar to as the prepared message in the Word document. This maintaining of format was / is still the case when pasting manually into gmail and many other places. ( This conversion to simple b/w is usually only seen when pasting into very simple basic text reply windows which supported no formatting )
Formatedtext.JPG ; https://imgur.com/A9Sq5Y1 PastedInGermanEMail https://imgur.com/CZRH5jj
( Here is the same after pasting into gmail: PastedIn gmail.Jpg https://imgur.com/CzqCJ7y )
Some thing similar was experienced when I recently wrote a compute program to directly send Emails:
This was the File used to produce the HTML code string to send
ProMessageTelekom.JPG : https://imgur.com/zn3BGWj
This came on as expected in most places, for example in gmail:
ProMessageArrivedAt gmail UsingCodeToSend.jpg : ProMessageTelekom.JPG : https://imgur.com/u57kRD7
But.…
.. The same sent to a German Telekom t-onlone.de address came on with a similar format loss problem to that experienced when pasting into the German Telekom Email Editor / Email Program
ProMessageRecievedAT tOnLinede UsingCodeToSend.JPG : https://imgur.com/h4wJVXd
_._______________________-
I looked at and compared a lot of different sent HTML strings , and examined what came into different places.
In other words I messed around empirically with the HTML string, and then took a look at how that effected the formatting actually seen in the final received and viewed Email.
I do not really understand HTML programming ( or anything much with computing for that matter ) so I do not know the significance of what I noticed.
However I was able to consistently ensure that the correct format was received , that is to say , the received Email looked very similar to as it had in the prepared Word document.
I went on to write an additional part , ( an extra Function ) which made the necessary changes to the HTML code string just before the final sending. This consistently resulted in the correctly looking Email being received.
Once again using the same example:
This was my prepared Word document, saved in .htm extension, and used in my code to produce the long string of HTML code text to send as an Email:
ProMessageTelekom.JPG : https://imgur.com/zn3BGWj
With the modified code, the received Email now looks like this:
ProMessageRecievedAT tOnLinede UsingModifiedCodeToSend.JPG : https://imgur.com/UuPdyOR
_._________
The code modification:
The existing code:
Part of the existing coding is a Function
( http://www.excelfox.com/forum/showth...0517#post10517 )
This uses the Word .htm file to produce the single ling string of HTML coding.
The final result is for that Function to return that string in the variable MyLengthyStreaming
Effectively the signature line of the Function defines / declares that variable thus:
Pubic Function MyLengthyStreaming() As String
VBA indeed holds a variable of name MyLengthyStreaming of String type whilst that Function code is running
That code line is then effectively, pseudo
xxxxDimxxxxxxx MyLengthyStreamingxx As String
In place of the normal “filling” of a variable by pseudo_...
xxstrvariablex = xxxxxxx
_.. we do something similar by
xxstrvariablex = MyLengthyStreaming()
The result is that the Main code execution pauses at this part MyLengthyStreaming() , whilst the function code , Function MyLengthyStreaming( ) is carried out. Then the main code resumes once that function is Ended. Generally the final result of the Function will be to fill the variable MyLengthyStreaming within that function. So then the complete execution of that code line _..
xxstrvariable[color=white]x[/color = MyLengthyStreaming()
_.. will return the filled value of MyLengthyStreaming into strvariable.
The above is a typical progressing when a main code Calls a function code.
Modification / additional Function
The strategy now is simply to modify the final string in MyLengthyStreaming within the function.
For convenience I have done this in another, second function,
Pubic Function MyLenghtyDiesScreaming_Telekom(ByVal MyLengfyScream As String) As String
This Function is called from within the first function, in this extra code line which is the main modification to the existing codes:
Let MyLengthyStreaming = MyLenghtyDiesScreaming_Telekom(MyLengthyStreaming)
This function differs slightly from the first function in that it contains an argument passed in the brackets ( _ )
Effectively the purpose of the function code is to use the value in MyLengthyStreaming before returning that modified value back into MyLengthyStreaming. So it modifies the HTML string in MyLengthyStreaming
Once again , this is one typical way that a function is used
The Function I have called Function MyLenghtyDiesScreaming_Telekom
It has the signature line of
Pubic Function MyLenghtyDiesScreaming_Telekom(ByVal MyLengfyScream As String) As String
Effectively the signature line Dim’s MyLenghtyDiesScreaming_Telekom as a String variable and MyLenghtyDiesScreaming_Telekom can be used as such in this function code. Assigning a variable to this in a main code will cause the value held by VBA in the variable MyLenghtyDiesScreaming_Telekom at that point to be out in the assigned variable, but first the main code will be paused at this “Ccalling” code line whilst the function code is carried out. So we have the chance to do something in the function to fill that variable, MyLenghtyDiesScreaming_Telekom . We can take one or more things in, in the ( __ ) to use . In this case we want to take a string in and then return it modified , hence the last code line is simply
MyLenghtyDiesScreaming_Telekom = MyLengfyScream
_.______
What is the main modification
After a lot of experimenting it appeared that the modification which mostly gave the desired end results were to do some simple exchanging of ' and "
As example a HTML part such as this_..
<p class=MsoNormalCxSpMiddle><span style='font-size:24.0pt;line-height:115%;
font-family:GungsuhChe;color:#0070C0'>W24 <span class=SpellE>GungsuhChe</span></span><span
style='font-size:24.0pt;line-height:115%;font-family: "Franklin Gothic Heavy", "sans-serif";
mso-fareast-font-family:Batang;color:#0070C0'> <o:p></o:p></span></p>
_..will be modified to this_..
<p class=MsoNormalCxSpMiddle><span style="font-size:24.0pt;line-height:115%;
font-family:GungsuhChe;color:#0070C0">W24 <span class=SpellE>GungsuhChe</span></span><span
style="font-size:24.0pt;line-height:115%;font-family: 'Franklin Gothic Heavy', 'sans-serif';
mso-fareast-font-family:Batang;color:#0070C0"> <o:p></o:p></span></p>
How is the main modification done
In VBA coding there are many ways to achieve the required modification. My final way is probably not the most efficient. But it is fairly easy to follow through, - I have ‘commented it extensively.
The modified first function and additional function is here:
Notes:
_1: The modification seemed to have no effect on the end result when the modified HTML string was sent in place of the original for other Email Program recipients other than German Telecom ( Deutsch Telekom ( Freemail t-online.de ) ), so I have not bothered to add anything to select use of the function only in the German Telekom recipient case. But this might be a more efficient development to do that later.
_2: I added a few bits to the function to remove the larger parts of the HTML coding that appeared not to be relevant to the main body text.
_.__________
Here is the modified initial function and the new second function:
http://www.excelfox.com/forum/showth...0528#post10528
-
5 Attachment(s)
Some Notes to Distinguish between these 2 Worksheet embedded Button types: ActiveX Control ; Form Control
Some Notes to help Distinguish between these Two Worksheet embedded Button types:
ActiveX Control ; and
Form Control
In these Threads:
I am asking for help in understanding and getting a simple Button in a Worksheet. That Button should set of a VBA macro code
This post is just some notes to clarify the two things that I am talking about…
Currently there are two ways to do this:
Form Control
ActiveX Control
For the case of a simple Button to start a macro, they appear to work fairly similarly. There is a lot of stuff “behind” them that I know nothing about. I would like to get familiar with them, and if possible both types up and running before deciding which / where to use.
So this post is just to make clear what I am talking about and give the basic characteristics and features of the two types, just so we all know what we are talking about , ( at least in terms of the very initial introduction of using them initially.
So…
Just to be clear what I am talking about..
The button things that I am talking about
I am talking about the things you “insert” into a worksheet like this…
Excel 2007+ (‘_- Find the hidden Development Ribbon Tab, then select the tools controls icon to get both of them ! :-)
https://support.office.com/en-us/art...AABAAA=Windows
http://www.jkp-ads.com/Articles/controls01.asp
Excel 2007+ Form and ActivX Control buttons.jpg https://imgur.com/x2OxFvX
https://app.box.com/s/st84weg49tjgj25x49iib8h1mv9gb7k4
Attachment 2022
( To get you back to 2003 Menu stuff should you be familiar and prefer : https://www.youtube.com/results?search_query=ubitmenu https://chandoo.org/wp/2009/10/19/ex...olbar-in-2007/ … and/ or then…. )
Excel 1997-2003
(‘_- a) Select the View Tab then select either or both of the controls Tool Bars , http://www.jkp-ads.com/Articles/controls01.asp https://imgur.com/VLv2uvM Excel 2003 Form and ActiveX Control buttons.jpg https://app.box.com/s/me97qpwtmzybm42ed8z876q19bd801o9
Attachment 2020
or b) Select the View Tab then select the Visual Basic tool bar, from which you can select the tools controls icon to get the ActiveX controls Tool bar :-) https://imgur.com/AqHDBBH http://www.jkp-ads.com/Articles/cont...nts=True#25922 Excel 2003 ActiveX Control button from VB Tool bar.jpg https://app.box.com/s/l40n0ktm5d8uzrswe3czyae2xby60hqa
Attachment 2021
_.................
General Stuff about them, what they are..
Form controls ( not to be confused with UserForms ) were an original part of Excel so allowed you to customise the Worksheet a bit. Probably one reason they were kept is to allow for backward compatibility. ( In the meantime they are probably kept as the alternative ActiveX stuff goes wrong a lot )
ActiveX was some attempt by Microsoft to combine some other stuff which was itself an attempt to combine or allow communication through a communicating object which then they tried a bit later to extend to embedding that object in stuff… ActiveX controls refer to a specific way of implementing the earlier technologies, and no one has any idea anymore exactly how it all works or what links still exist when they “run” , so it is no surprise it has turned into a mess where things go wrong and no one is quite sure why.
ActiveX things have a strong reputation of breaking themselves or breaking other stuff, ( maybe because of all the attempt at linking stuff that they are supposed to do? ) so they can really mess things up basically. Viruses for example can slip through all the links or routes that get set up and which no one remembers anything about. ( I keep seeing myself that they suddenly do not work for no apparent reason. I have not managed to get ActiveX controls Buttons to work at all yet on a couple of computers with Excel 2003 ). It sounds like you need to be a bit of a computer expert in a lot of stuff outside Excel if you use ActiveX controls Command Buttons because of all the damage they may cause.
ActiveX controls
It would appear that the word ActiveX could almost apply to anything. The ActiveX control things here might be described as the ones optimised for internet, Internet Explorer, but which also work, as I am using them, in Microsoft Office
( ActiveX controls don’t work on a Mac: I expect that is because they are attempting to link a lot of Microsoft stuff, so it would be a mammoth task to get them working outside a Microsoft environment, especially as they don’t work very well in the Microsoft environment either , not that is of interest to me )
Codes associated with / assigned to a “Worksheet Button”
Form Control code
To see the code already assigned to an Excel Form control button you select the option to assign it which you get in a menu when you click right mouse when the mouse cursor is in it. Then it will highlight the current Sub assigned it.
ActiveX Control code
( Right clicking will have the same effect as left click, that is to say activate/ press the button.
You need to get into “design mode”, then the right click will get you the code…..)
To see the code with a Command button ActiveX control you first have to select the Design mode icon which is next to the Controls icon in:
( For Excel 2007+ the Ribbon from the Visual Basic Development Tab ( https://imgur.com/MqVC6jB ); Excel 2007+ Form and ActivX Control buttons and ActiveX Design Mode .JPG https://app.box.com/s/3udml4bnnn07um7lgeg0uwpuczj8m0pm
Attachment 2022
and
For Excel 2003 the Visual Basic Development Tool Bar or ActiveX controls Tool bar ( https://imgur.com/yR2491F ). Excel 2003 ActiveX Control button from VB Tool bar.JPG https://app.box.com/s/l40n0ktm5d8uzrswe3czyae2xby60hqa
Attachment 2021
Once in Design Mode, a right click when the cursor is in a ActiveX controls Command Button will give you the option to view the code , and on selecting that option, the appropriate worksheet code module will pop up. )
Text on the Button:
ActiveX control
For an ActiveX control button you also need to do that select the Design mode icon step to be able to edit the text on the ActiveX button ( which you then do by a right click on the button followed by selecting Properties option. Then you can edit the Caption Property from the Property Window that comes up ) , and it appears that the text can only be in a single line. It would appear that the caption is a property of an under Object within the Worksheet Object ( https://imgur.com/MqVC6jB ).
Form control
For a Form controls Command Button to change the text you right click on the button then select the text and you can change it and also , it appears have the text on multiple lines
Codes sorts behind them:
ActiveX control
ActiveX controls Command Buttons are a sort of “Eventy Clickies** thingy”, so the code has to go in the Worksheet Code module of the Worksheet in which it is. So a specific ActiveX controls Command Button is a VBA Object thingy. It gets called a Private Sub when you add / Insert it. You can change it to Public Sub , and that does not seem to make much difference
( ** So you can have other codes with an ActiveX control, reacting on additional things such as passing over a Button.
CommandButtonClickies.JPG : https://imgur.com/uxkIpZS
Attachment 2023
For the Form control you just have the click ……. )
Form control
I don’t quite know what sort of a thing a Form controls Command Button is. It is a pseudo a single event ( click ) Thing: You assign one code to it. You can do that, for example, by clicking on the right mouse when the mouse cursor is on it, followed by selecting the option to assign a macro after which the pop up macro assign window should pop up. It appears to me###, based on my experiments, that the code can go anywhere and can be Private Sub or Public Sub, ( although you will not get it offered as one to choose from in the pop up macro assign window, if you make it a Private Sub. ( ###This observation from me contradicts some stuff I have read which says the codes are always written in normal modules… well they ain’t by me .. and no ill effects yet )
Ref:
https://www.excelforum.com/excel-pro...ml#post4787311
https://www.excelforum.com/excel-pro...ml#post4789873
-
3 Attachment(s)
List of, and search of Updates on Computer:
Some additional notes on things broken ActiveX controls..
These are just some additional notes in support of other Forum Threads on the Theme of things “broken by / with ActiveX controls”
http://www.excelfox.com/forum/showth...en-insert-them
http://www.excelfox.com/forum/showth...ommand-Buttons
http://www.excelfox.com/forum/showth...0586#post10586
List of, and search of Updates on Computer:
Often one hears that updates can cause problems with things “Activia X y controlly” . This Post considers ways to automate seeing what you have and checking for particular ones reported to have given problems with ActiveX controls…….
( Actually what we are doing here is to get a list of updates on a computer and / or search through/ for them. So this post may be of general interest when looking for any updates on a computer ).
Old black box command Dosy Window looking at Files stuff
Getting a window up that looks like an old black screened computer up and typing simple old computer type commands seems to be what one often uses when delving into these sort of things, so that is a good start point.. ( I think this window thing is possibly similar to the console Window thingy in Visual Basic https://www.mrexcel.com/forum/genera...ml#post4357648 )
Get it up
From Hans here: http://www.eileenslounge.com/viewtop...=28682#p222044
http://www.eileenslounge.com/viewtop...=28682#p222044
_ Press _ Windows key + r _ to activate the Run dialog
Windows+r.JPG : https://imgur.com/1KI8nok
Attachment 2024
_ Type in box bar _ cmd _ if not already shown
cmdInBoxBar.JPG : https://imgur.com/L9saGzj
Attachment 2025
_ Press _ Ctrl+Shift+Enter _ to start an "elevated" command prompt.
ElevatedCommandPrompt.JPG : https://imgur.com/W1p6frJ
Attachment 2026
Get a list of Updates in a text file
Note: In the following steps you need to type a few things in exactly as given. I have sometimes experienced problems with characters not working and / or pasting in not working. But usually one or a combination of the following will work
_ (i) If you are lucky you can type all characters.
_ (ii) Copy text from here and paste in using _ Ctrl+v
_ (iii) Copy text from here and past in using _ option given when clicking right mouse
_ To get a text file produced, for example on your desktop, type in a single code line something like these examples , using a file path to suit you:
Code:
wmic qfe get hotfixid > C:\Users\Elston\Desktop\UpdatesOnVistaAspire4810TZG25thMarch.txt
wmic qfe get hotfixid > C:\Users\Alan\Desktop\UpdatesAcerMartinWin7Pro64Bit26thMarch.txt
It may take a few seconds, and then you should see a text file appear ( in this case it appeared on my desktop because I put that path in ) looking something like this : https://imgur.com/9Ze2FY6
Here is the first part of the text file on one computer.
Code:
HotFixID
{EF8CD7FC-438D-49E3-A2C7-201052D9F2EF}
{8D2CDFAB-0079-43CC-A289-2F7A67F0A4DE}
{98D8F490-1F42-4F29-A59B-BF96D23A11BA}
{B730F010-3FCF-4E80-8A5A-C1DBEC0CF55A}
{B73E5AF4-40C6-4EA9-8F57-CFA70CC72BD6}
{BF11577A-6876-45AA-86C9-2BA4CFB8B019}
{E359D786-B101-4545-B8AB-8652323CF3CA}
{F4139440-5426-4C6F-909B-F71CEB1071B1}
{B2FAD7E1-67F9-435D-98BD-A77DBF4E1381}
{0CC8FAD2-05D8-4A0A-9E5C-2CDACFF86996}
{0EF0D4FB-BB23-4515-AAEA-1240AC2DA525}
{800D1A82-D1B0-4ED4-89B4-C666B570ABA5}
{8D2CDFAB-0079-43CC-A289-2F7A67F0A4DE}
{98D8F490-1F42-4F29-A59B-BF96D23A11BA}
{BF11577A-6876-45AA-86C9-2BA4CFB8B019}
{E359D786-B101-4545-B8AB-8652323CF3CA}
{F4139440-5426-4C6F-909B-F71CEB1071B1}
{B73E5AF4-40C6-4EA9-8F57-CFA70CC72BD6}
{D6C976E4-E88C-4048-9A6B-39400D2933C7}
{FC8EA2A2-65A3-366E-A687-5B63943A800F}
{6F8500D2-A80F-3347-9081-B41E71C8592B}
{AC76BA86-7AD7-0000-2550-7A8C40011010}
{FC8EA2A2-65A3-366E-A687-5B63943A800F}
{D758F295-2DE9-4A95-B857-B18BF52A26B2}
{E94DDFCD-6D84-40A4-B5DF-24AE25761924}
KB971513
KB971512
KB982861
982861
KB960362
942567
KB971514
KB2761494
KB2079403
KB2117917
KB2141007
Here is the uploaded text file obtained from a couple of my computers
“UpdatesOnVistaAspire4810TZG25thMarch.txt” : https://app.box.com/s/z90o8yj7iz0188yci34mu7gahe2tfhce
“UpdatesAcerMartinWin7Pro64Bit26thMarch.txt” : https://app.box.com/s/8m96l0e7yh1wcb15y06eaaz6a7vtjzgd
It would be nice to automate that . I Don’t know how :(
Never mind. In any case you should now be able to get a list
Search the list for specific updates updates
A few ways…
( A way without using the text file )
_ use the command like : _ wmic qfe get hotfixid | find "KB1234567"
If KB1234567 is installed, you'll see KB1234567 on the next line, otherwise it'll remain blank. : http://www.eileenslounge.com/viewtop...=28682#p222044
https://imgur.com/9Ze2FY6
( Ways using the text file )
_ Knacker your eyes looking through the text file
_ You may be able to do a simple search with your text editor. Using Notepad I can get a search from the following options from the top of the open editor window of something like __
--- Bearbeiten --- Suchen
or
---- Edit --- Search
or
using the shortcut key combination __ Ctrl+f
You then have a search window in which you can type in what you want to find
Note however: I think there are sometime some strange characters that are not always visible to you, and then a search may fail as it won’t make a perfect match possibly. I am not too sure exactly what I mean there, but others have told me some quirky things can happen such that that text search fails…
The next way can help over come that ###
_ It can easily be automated to search the text file using VBA. I prefer to do this mainly as it is less likely for me to make a mistake, but also as I have found some strange characters coming in to dirty/corrupt the string of the update, and the search can be done for a match on part of the string which will help offset the problem of missing a match due to the string corruption ###
Here is a simple code.
Sub CheqUpDates()
http://www.excelfox.com/forum/showth...0586#post10586
You input the Updates that you want to search for with one or more spaces in between, and you can type in just part of the character string. All matches will be returned in a string in a message box, and also that string is available to be copied from the immediate window.
-
2 Attachment(s)
Code to make Day list from Excel File and show in Pop up Word .htm File
Code to make Day list from Excel File and show in Pop up Word .htm File.
MakeTagList Button , Sub MakeTagList()
This post gives some Overview notes for later reference to help clarify some other more detailed excelfox Threads.
MakeTagList Button. Briefly, overview:
The code Sub MakeTagList(), primarily does two things:
_ makes a simple text file with the important details from a Daily Diet Protocol
DailyTextFileForEmailAttatchment.JPG : https://imgur.com/MqEmlDF
Attachment 2053
_ makes a long string of HTML coding which if written to a text file, (but with the usually given .txt extension replaced with .htm ), is recognised by Microsoft Word which can open it in a form which looks similar to a normal Word doc
That Word File is opened temporarily to show a pretty table form of the important details from a Daily Diet Protocol:
TemporaryWordPopUp.JPG : https://imgur.com/ZFhsdaQ
Attachment 2054
_.___________
_ makes a simple text file with the important details from a Daily Diet Protocol
arrNuts()
The start point is that an array is made of used food products from daily pro, arrNuts()
arrNuts() is the = Items() array from a Dictionary. So it is a one dimension array starting at arrNuts(0). Each Element is a row from the from the Daily Excel Diet Protocol File, “ProAktuellex8600x2.xlsm”. It is built up from a line like pseudo
Code:
Key:=ProRow with Entry in C column, Item:=Array(FoodProduct in 1st Column A , amount eaten from 3rd Column C , Kcal total in 9th column I , Fett , Eiweiß …. Etc.
( The Key is not used currently )
Rem 5 Text File
A text file is made from the array with a pipe, _ | _ , as separator like from:
arrNuts(0)(0) & “|” & arrNuts(0)(1) & “|” & arrNuts(0)(2) ……..etc..
arrNuts(1)(0) & “|” & arrNuts(1)(1) & “|” & arrNuts(1)(2) ……..etc..
arrNuts(2)(0) & …..etc..
The final text file is stored in the same Folder as most of the files to do with daily protocols, that is to say, the currently used main Folder . It is given a name something of the form pseudo
“MonatsUebersichtAnhang " & Date in format like "mmmm yyyy" & “.txt”
As example for any day in April, 2018, it will be like
“MonatsUebersichtAnhang April 2018.txt”
The main purpose of this text file is to have a file that can be attached to an Email which at the receiving end can then be for recording and using the important daily nutrition values in a graphic
I use the standard VBA type code lines for this , pseudo like
Open C: \ __ \ _ \ ¬¬¬-___“MonatsUebersichtAnhang April 2018.txt” For __ As __
_.___________
_ makes a long string of HTML coding which if written to a text file, (but with the usually given .txt extension replaced with .htm ), is recognised by Microsoft Word and can opens it in a form which looks similar to a normal Word doc
Rem 6 .htm Word Template File
An empty or almost empty .htm Word file, “DailyProtable.htm “ , ( which should be in the main currently used Folder already , - ( download from box if necessary ) ) is converted into a single very long String variable , TotalFile
I use the fairly standard VBA way often used to get this long string from a .txt file. It seems to work equally well for a .htm file
Code:
Rem 6 get Template File as long HTML string . Template file is an almost empty Word .htm file.
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & "\" & "DailyProtable.htm" ' Template file never changes
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundemental type data input...
TotalFile = Space(LOF(FileNum)) '....and wot recives it hs to be a string of exactly the right length
Get #FileNum, , TotalFile
Close #FileNum
Rem 7 modify main body text section of the template file
Rem 7
Things start getting a bit complicated now. It may help at this point to give a summary of the overall goal:
The final aim of this code and the associated code usually done just after, Sub PetrasDailyProWay1_COM_Way() , is to get a pretty summary table in a HTML code such as it is in a form that can be used for two things:
_ Temporarily in a Word .htm file which is opened temporarily to show the current stand of a finished or almost finished protocol,
_ part of that ( the main body part ) can be isolated into a functioning variable , MyLengthyStreaming , and used in the typical LECMO technology code lines of the form
CDO.Message.HTMLBody = MyLengthyStreaming
CDO.Message.Send
( In actual fact the entire Word.htm HTML string, TotalFile , could usually be used, but I do not do this as
_ TotalFile has a lot of unnecessary text, presumably needed for Word .htm file recognition
as well as
_ there are some subtle problems which need to be addresses with the string before it can be used with German Telekom, as it appears that a Bug means that the German Telekom does not quite recognise correctly that standard HTML coding ( gmail and AOL seem not to have this problem ) https://telekomhilft.telekom.de/t5/E...136416#M129791 )
What basically needs to be done is to modify the TotalFile at the main body part. This Part of the text is almost empty at this stage. That almost empty main body part is replaced by a made pretty HTML table
It is all done in a bit of a messy way, and it is easy to lose track of what is going on. Once again, the purpose of this code:
The code Sub MakeTagList(), primarily
_ makes a simple text file with the important details from a Daily Diet Protocol
_ makes a long string of HTML coding which if written to a text file, (but with the usually given .txt extension replaced with .htm ), is recognised by Microsoft Word and can opens it in a form which looks similar to a normal Word doc
_ makes a long string of HTML coding which if written to a text file, (but with the usually given .txt extension replaced with .htm ), is recognised by Microsoft Word and can opens it in a form which looks similar to a normal Word doc
In Rem 7 we basically embed a Table ( in HTML coding form ) by doing a simple Replace of the start part of the main body in the string from the Template .htm file which looks like this
<div class=WordSection1> ( You can see that yourself if you open up the .htm file using a simple text editor, and look towards the end MainWordSectionBody.JPG : https://imgur.com/HWjHTyz )
That existing HTML coding, <div class=WordSection1> , is Replaced by
<div class=WordSection1> & A made HTML table done in a Function
That Function is called using the arrNuts() thus:
ProTble(arrNuts())
Function ProTble()
By a bit of trial and error and learning some basic HTML coding I was able to write this function which based on the data given in arrNuts() gives a lot of HTML coding which a Browser ( or Word when it has it included in the long HTML string opened using a .htm extension file ) can understand and produce a table formatted as I want:
Rem 8
Back in the main code we now have our original full file text string of HTML coding, TotalFile , modified to include in it the pretty table
The string is printed out to a text file in the usually way but with the .htm extension instead of the usual .txt extension. This file is currently given the name
"DailyProtableFilled.htm"
Code:
Rem 8 Over write the last ( likely yesterdays ) filled file, with the modified template file which is mainly still that what Word recognises as we only modified a bit of the main text body
Dim HighwayToHelloPro As Long ' For rewrite of modified DailyProtable.htm as DailyProtable.htm2
Let HighwayToHelloPro = FreeFile(0)
Open ThisWorkbook.Path & "\" & "DailyProtableFilled.htm" For Output As #HighwayToHelloPro ' Will be made if not there, and overwritten as Output rahter than Append
Print #HighwayToHelloPro, TotalFile
Close #HighwayToHelloPro
Rem 9 get Word using Excel
Rem 9
The final part of the code, Sub MakeTagList() , which is initiated by the Button, MakeTagList , brings up the file, "DailyProtableFilled.htm" , temporarily in Microsoft Word.
_.___________
Required Files:
Daily Diet Protocol :
“ProAktuellex8600x2.xlsm” :
https://app.box.com/s/fpztob9pcp92fl6hh81zgpzumw9ntcp0 ( Current )
https://www.magentacloud.de/share/38m-zuc2y3#$/ ( April 2018 )
Main Makro File:
“NeuProAktuelleMakros.xlsm” :
https://app.box.com/s/e93u19xidygreeeenlxyupm750dxe33f ( Current )
https://www.magentacloud.de/share/38m-zuc2y3#$/ ( April 2018 )
Usually in practical use, the execution of the last coding would be followed by the sending of the EMail using the Send Pro Mail Button.
Ref:
http://www.eileenslounge.com/viewtop...=29556#p228710
http://www.excelfox.com/forum/showth...0528#post10528
-
3 Attachment(s)
Formating Tables sent via EMail using LECMO/CDO Technologies. htm html web site range publish
Background testing work for this Thread:
http://www.excelfox.com/forum/showth...and-send-email
Also related to these Threads and Blogs
http://www.eileenslounge.com/viewtop...=29556#p228710
https://msdn.microsoft.com/en-us/lib...toSendingEMail
http://www.excelfox.com/forum/showth...0632#post10632
http://www.excelfox.com/forum/showth...once#post10518
< HTML HTM > coding
At least until recently, the “language” most commonly used or seen in Internet and World wide web electronic communication is the “pointy bracket” type,” ( Hypertext Markup Language https://en.wikipedia.org/wiki/HTML https://www.youtube.com/watch?v=1gLh...D6F7E289625976 “ ) , which to a large part of most such coding consist of pairs of “start” and “stop” “tags” in a long string to tell something about what is within the tags, like, pseudo code example
HTML Code:
<AText>This might be a final text you might “see” in something like an Internet Browser which can “read” HTML coding</AText><nextInstruction>………
or, for convenience this often is seen in a “.html” file, if viewed in the code form, like
HTML Code:
<AText>
This might be a final text you might “see”…….
</AText>
<nextInstruction>………
( In a VBA code the last code string would be typically constructed something like this :
Code:
= “<AText>” & vbCrLf & “This might be a final text you might “ & “””” & “see” & “””” & ”…….” & vbCrLf & “</AText>” & “<nextInstruction> ….
Or this:
Code:
= “<AText>” & vbCrLf & “This might be a final text you might ““see””…….” & vbCrLf & “</AText>” & “<nextInstruction> ….
…….. )
The extra carriage returns and / or Line feeds (vbCr , vbLf , vbCrLf ) , in the total string, as in the last code form would typically be ignored by any
Various software is available which can read that HTML coding. The most commonly known thereof being the internet browsers most commonly available, such as Internet Explorer from Microsoft, or Google Chrome from Google. Basically an Internet Browsers main function is to receive and read the HTML coding which is typically passed in Internet and World wide web electronic communication
So basically , if that HTML file is “fed” to something, such as an internet browser, then you, as final user/observer, would finally see something like this:
___This might be a final text you might “see” in something like an Internet Browser which can “read” HTML coding
Here an example of Internet browser, Google Chrome, used for receiving Emails , using the Email provider software of gmail and German Telekom
SeenIngmailOrGermanTelekom.JPG : https://imgur.com/Oz6z6tq
Attachment 2068
Using this language you can make many other things “appear” in addition to simple text.
Currently I am interested in extending the “seen” message developed in posts around here, gmailInputRunOnThursday7thJune bw table.JPG : https://imgur.com/Dh38G4O , to include some colouring and possibly heading information
So I have this:
gmailInputRunOnThursday7thJune bw table.JPG : https://imgur.com/Dh38G4O
Attachment 2066
But I want something more like this:
Quote:
Originally Posted by
Thainguyen
Attachment 2067
This is basically the Excel range format in the file from which the Information comes
Using Excel 2007 32 bit
Row\Col |
A |
B |
C |
D |
E |
F |
G |
H |
I |
J |
K |
1 |
Equipment PM |
|
|
|
|
|
|
|
|
|
|
2 |
Machine EQ.ID |
Manufacture |
Model |
Description |
Serial Number |
Weekly
Date of Service |
Weekly
Next Service |
Monthly
Date of Service |
Monthly
Next Service |
Quarterly
Date of Service |
Quarterly
Next Service |
3 |
|
|
|
|
|
|
|
|
|
|
|
4 |
1 |
JUKI |
GKG GL |
GL SCREEN PRINTER |
A123 |
06.04.2018 |
13.04.2018 |
15.03.2018 |
12.04.2018 |
N/A |
N/A |
18 |
137 |
Juki |
K3 |
Screen printer |
A137 |
03.06.2018 |
10.06.2018 |
N/A |
N/A |
N/A |
N/A |
19 |
141 |
Heller |
1826 MK5 |
Reflow Oven |
A138 |
N/A |
N/A |
13.05.2018 |
10.06.2018 |
N/A |
N/A |
20 |
142 |
NISSAN |
MCU-112A331.V |
Forklift |
A139 |
N/A |
N/A |
N/A |
N/A |
13.05.2018 |
10.06.2018 |
21 |
142 |
NISSAN/yearly oil change and lube |
MCU-112A331.V |
Forklift |
A140 |
N/A |
N/A |
N/A |
N/A |
N/A |
N/A |
22 |
|
|
|
|
|
|
|
|
|
|
28.01.1900 |
Worksheet: Equipment PM
_.___________________
HTML tolerates many mistakes + Microsoft files can be saved as .htm/html type
Here are a couple of interesting and relevant observations:
_(i) It would appear the HTML coding is quite tolerant of mistakes or having additional code lines, or Tag pairs that it does not recognise. Sometimes a large amount of coding will be accepted, and only a small part will be read and used successfully to give a “seen” output.
_(ii) Microsoft Word and Microsoft Excel Files can be saved as .htm extension instead of the more common extensions ( .xls , .doc , .xlsx etc…
Because of these two things, it is possible to save a File in such a way, and then use that as the HTML coding used in the Email sending codes which are being discussed here , ( https://tinyurl.com/y8gxucsl , https://tinyurl.com/yacekv4o , http://www.excelfox.com/forum/showth...mail#post10670 , http://www.excelfox.com/forum/showth...once#post10518 )
So, pseudo code part like this would be used
Code:
Dim strHTML As String: Let strHTML = The String of HTML coding obtained from a saved as .htm Word or Excel File
.htmlbody = strHTML
Such a technique is often done. Sometimes only a part of an Excel spreadsheet is wanted and this can also be saved in a .htm extension.
When using this technique, a lot of extra HTML coding is present which is not needed or recognised when used for the sent Email. As noted, this does not normally cause problems.
( often this technique goes by the name of Publishing or range publishing )
I personally prefer to examine the HTML coding and pick out only the information I need. This is the way I personally prefer to do it
In the next post I will look at this last way of doing things. I will use the example of the required ….. “….I wonder if we can include like the picture below ….”……
Quote:
Originally Posted by
Thainguyen