Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 10-02-2022, 03:25 PM
Guessed's Avatar
Guessed Guessed is offline Replace umlauts in fields Windows 10 Replace umlauts in fields Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Yes, I forgot to add a Len() around the second part of that code. Try changing that line to
Code:
Sub ReplaceUM()
  Dim aFld As Field, sCode As String, sFind As String, sRep As String
  Dim sInner As String, i As Integer, i1 As Integer, i2 As Integer
  Dim sPre As String, sPost As String
  sFind = "äöü "
  sRep = "aou_"
  For Each aFld In ActiveDocument.Fields
    If aFld.Type = wdFieldIncludePicture Then
      sCode = aFld.Code.Text
      If Len(sCode) - Len(Replace(sCode, """", "")) > 1 Then
        i1 = InStr(sCode, """")
        sInner = Mid(sCode, i1 + 1)
        i2 = InStr(sInner, """")
        sInner = Mid(sInner, 1, i2 - 1)
        sPre = Left(sCode, i1)
        sPost = Mid(sCode, i1 + i2)
        Debug.Print sCode, sInner, sPre, sPost
        For i = 1 To Len(sFind)
          sInner = Replace(sInner, Mid(sFind, i, 1), Mid(sRep, i, 1))
        Next i
        aFld.Code.Text = sPre & sInner & sPost
        aFld.Update
      End If
    End If
  Next aFld
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 



Other Forums: Access Forums

All times are GMT -7. The time now is 09:31 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft