Ændre fronte i vba
HejJeg har lavet en foreløbig VBA kode i Excel der opretter et Word dokument.
Jeg vil gerne kunne ændre udseendet af teksten, fx fed, kursiv, og hele typografier til fx overskrifter.
----------------------------------------------------
Sub Flet()
Dim Wdapp As Object
Dim Navn As String
Dim Adr As String
Dim PnrBy As String
Navn = Range("B2").Value
Adr = Range("B3").Value
PnrBy = Range("B4").Value & " " & Range("B5").Value
On Error Resume Next
Set Wdapp = GetObject(, "Word.application")
If Err.Number <> 0 Then
Set Wdapp = CreateObject("Word.Application")
End If
Wdapp.Documents.Add
Wdapp.Selection.TypeText Text:=Navn
Wdapp.Selection.TypeParagraph
Wdapp.Selection.TypeText Text:=Adr
Wdapp.Selection.TypeParagraph
Wdapp.Selection.TypeText Text:=PnrBy
Wdapp.Selection.TypeParagraph
Wdapp.Selection.TypeParagraph
Wdapp.Selection.TypeParagraph
Wdapp.Selection.TypeText Text:="Kære " & Left(Navn, InStr(1, Navn, " "))
Wdapp.Selection.TypeParagraph
Range("a1").Activate
Wdapp.Visible = True
Wdapp.Activate
Set Wdapp = Nothing
End Sub
----------------------------------------------------