VB i Word ComboBox
Hej,Jeg har et problem med et få nogle valgmuligheder ind i to combobox´e i word!
Når jeg dobbelt klikker på den skabelon jeg har lavet kommer min "popup" box fint frem men der er ikke noget i de to combobox´e.
Jeg håber at der er nogle der kan hjælpe :-)
--->
Const f1 = "<chapter>"
Const f2 = "<category>"
Private Sub CommandButton1_Click() 'OK
If Me.ComboBox1 <> "" And Me.ComboBox2 <> "" Then
Rem navn - adresse - postnr by
søgErstatTekst f1, Me.ComboBox1
søgErstatTekst f2, Me.ComboBox2
Else
MsgBox ("Both input areas must be filled out!")
End If
Unload UserForm1
End Sub
Public Sub søgErstatTekst(sTekst, eTekst)
Dim rngStory As Word.Range
Dim pFindTxt As String
Dim pReplaceTxt As String
Dim lngJunk As Long
Dim oShp As Shape
pFindTxt = sTekst
If pFindTxt = "" Then
MsgBox "Cancelled by User"
Exit Sub
End If
TryAgain:
pReplaceTxt = eTekst
If pReplaceTxt = "" Then
If MsgBox("Do you just want to delete the found text?", _
vbYesNoCancel) = vbNo Then
GoTo TryAgain
ElseIf vbCancel Then
MsgBox "Cancelled by User."
Exit Sub
End If
End If
'Fix the skipped blank Header/Footer problem
lngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryType
'Iterate through all story types in the current document
For Each rngStory In ActiveDocument.StoryRanges
'Iterate through all linked stories
Do
SearchAndReplaceInStory rngStory, pFindTxt, pReplaceTxt
On Error Resume Next
Select Case rngStory.StoryType
Case 6, 7, 8, 9, 10, 11
If rngStory.ShapeRange.Count > 0 Then
For Each oShp In rngStory.ShapeRange
If oShp.TextFrame.HasText Then
SearchAndReplaceInStory oShp.TextFrame.TextRange, _
pFindTxt, pReplaceTxt
End If
Next
End If
Case Else
'Do Nothing
End Select
On Error GoTo 0
'Get next linked story (if any)
Set rngStory = rngStory.NextStoryRange
Loop Until rngStory Is Nothing
Next
End Sub
Public Sub SearchAndReplaceInStory(ByVal rngStory As Word.Range, _
ByVal strSearch As String, ByVal strReplace As String)
With rngStory.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = strSearch
.Replacement.Text = strReplace
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
End Sub
Private Sub UserForm_Click()
End Sub
