"Niels Henriksen" <new@biggs.dk> wrote in message
news:a1uukt$1v6h$1@news.cybercity.dk...
> Hejsa
>
> Jeg skal bruge en rutine, der kan erstatte nogle ord i Word
> med data som man indtaster i et VB-prog.
>
> Nogle der har noget?
>
> --
> Niels Henriksen
Hej Niels
Dette er et eksempel, som du måske kan bruge som
inspiration. Dette er dog skrevet i VBA, men der burde ikke
være den store forskel. Du skal nok huske at sætte en
reference til Microsoft Word 8.0 Object Library.
Option Explicit
Public Sub replaceWords(strOldWord As String, _
                        strNewWord As String)
  ' Reference til Word applikationen
  ' og til dokumentet
  Dim wdApp As Word.Application
  Dim myDoc As Word.Document
  ' Åben Word i baggrunden og åben et dokument
  Set wdApp = New Word.Application
  Set myDoc = wdApp.Documents.Open("C:\My " & _
              "Documents\Usenet\Meget tekst.doc")
  ' Skjul Word
  wdApp.Visible = False
  wdApp.Selection.Find.ClearFormatting
  wdApp.Selection.Find.Replacement.ClearFormatting
  ' Erstat alle forekomster af strOldWord med strNewWord
  With wdApp.Selection.Find
    .Text = strOldWord
    .Replacement.Text = strNewWord
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
  End With
  wdApp.Selection.Find.Execute Replace:=wdReplaceAll
  ' Luk Word og gem dokument
  wdApp.Quit True
  Set wdApp = Nothing
  Set myDoc = Nothing
End Sub
Håber du kan bruge det til noget 
 
--
Mikkel Bundgaard
IT University of Copenhagen
http://officehelp.gone.dk
Codito, Ergo Sum