Cod: Selectaţi tot
dim txt1, txt2, txt3, txt4 as string
txt1 = "primul text"
txt2 = "textul doi"
txt3 = "textul trei"
txt4 = "textul patru"
srcString = txt1, txt2
dstString = txt3, txt4
practic ce am gresit?
Cod: Selectaţi tot
dim txt1, txt2, txt3, txt4 as string
txt1 = "primul text"
txt2 = "textul doi"
txt3 = "textul trei"
txt4 = "textul patru"
srcString = txt1, txt2
dstString = txt3, txt4
Cod: Selectaţi tot
srcString = txt1, txt2
Cod: Selectaţi tot
srcString = txt1 & "," & txt2
Cod: Selectaţi tot
srcString = "primul text, textul doi"
Cod: Selectaţi tot
Sub ReplaceQuotes()
Dim vFindText As Variant
Dim vReplText As Variant
Dim sFormat As Boolean
Dim sQuotes As String
Dim i As Long
'Ask the user whether to format with smart or straight quotes
sQuotes = MsgBox("Click 'Yes' to convert smart quotes to straight quotes." & vbCr & _
"Click 'No' to convert straight quotes to smart quotes.", _
vbYesNo, "Convert quotes")
'Record the current setting of the autoformat option to replace straight quotes with smart quotes
sFormat = Options.AutoFormatAsYouTypeReplaceQuotes
If sQuotes = vbYes Then 'The user has clicked 'Yes'
'Define the lists of smart quotes and their replacements
vFindText = Array(Chr(147), Chr(148), Chr(145), Chr(146))
vReplText = Array(Chr(34), Chr(34), Chr(39), Chr(39))
'Set the autoformat option to replace straight quotes with smart quotes to off
Options.AutoFormatAsYouTypeReplaceQuotes = False
'Start from the top of the document
Selection.HomeKey wdStory
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
'replace each item from the first array with the corresponding item in the second array
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = vReplText(i)
.Execute Replace:=wdReplaceAll
Next i
End With
Else 'User clicked 'No'
'Use autoformat to replace straight quotes with smart quotes
Options.AutoFormatReplaceQuotes = True
Selection.Range.AutoFormat
End If
'Finally reset the autoformat setting to its start configuration
Options.AutoFormatAsYouTypeReplaceQuotes = sFormat
End Sub
Nu stiu despre care "procedura de mai sus" vorbesti tu... dar sa stii ca ambele sunt la fel - si codul recomandat de mine si cel postat de tine mai sus fac exact acelai lucru, singura diferenta ar fi ca la mine "bucla" de cautare apeleaza o functie pe cand la ei aceeasi "bucla" este in aceeasi procedura.ccirtina scrie: in loc sa caut si sa inlocuiesc pe fiecare in parte (procedura lunga), sa folosesc procedura de mai sus care mi se pare foarte eficace.
Centrul de training si consultanta IT Learning activeaza de peste 15 ani pe piata serviciilor de instruire si certificare IT din Romania. |
Link-uri utile |
Categorii de cursuri |
Contact |
© 2019 IT Learning Business Intelligence School - Citeste termeni si conditii |