Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-30-2022, 01:30 AM
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

This is tricky because you don't want to replace every space in the code, just the ones between the double quotes. This code should get you started but it will need some checks in there to not destroy other fields.


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
    sCode = aFld.Code.Text
    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
  Next aFld
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #2  
Old 09-30-2022, 02:25 AM
Wrox23 Wrox23 is offline Replace umlauts in fields Windows 11 Replace umlauts in fields Office 2021
Novice
Replace umlauts in fields
 
Join Date: Sep 2022
Posts: 12
Wrox23 is on a distinguished road
Default Invalid procedure call or argument

Hi Andrew,

Thank you very much for the code. Seems to be a good approach. However, on first quick tests, calling the procedure resulted in an error:

Code:
Invalid procedure call or argument.
Depending on the text it comes already immediately or after some passes. In some texts the procedure does everything correctly until about the middle and only then exits. The rest of the text then remains as it is. In other texts it exits immediately.

I will try to find a solution.

Many greetings - Lothar
Reply With Quote
Reply



Other Forums: Access Forums

All times are GMT -7. The time now is 02:36 AM.


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