Gruppe
Extern
Problem
An ein Wordmakro soll ein Parameter übergeben und von dort zurückgegeben werden.
StandardModule: Modul1
Sub CallWordMacro()
Dim wdApp As Object
Dim wdDoc As Object
Dim vWert As Variant
On Error GoTo ERRORHANDLER
vWert = "1,95583"
Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.documents.Open( _
ThisWorkbook.Path & "\WordMakro.doc")
On Error Resume Next
wdDoc.CustomDocumentProperties.Add _
Name:="Wert", _
Value:=vWert, _
LinkToContent:=False, _
Type:=msoPropertyTypeString
If Err > 0 Then
wdDoc.CustomDocumentProperties("Wert").Value = vWert
End If
wdApp.documents.Open ThisWorkbook.Path & "\WordMakro.doc"
wdApp.Run "WD.Modul1.Meldung"
vWert = CDbl(wdDoc.CustomDocumentProperties("Wert"))
MsgBox vWert
ERRORHANDLER:
wdApp.Quit
Set wdDoc = Nothing
Set wdApp = Nothing
End Sub