J
Julian
As we all know, we can create a macro in word like this:
Sub Macro1()
'Using default paragraphs(1)
ActiveDocument.Paragraphs(1).Range.Text = "Date:"
ActiveDocument.Paragraphs(1).Range.Select
Selection.MoveRight
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldDate
End Sub
These codes work fine
Now we check how this work in excel(version 2003)
Private Sub CommandButton1_Click()
Dim oWord As Object
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Documents.Add
Set CurrentDoc = oWord.Documents(1)
CurrentDoc.Paragraphs(1).Range.Text = "Date:"
CurrentDoc.Paragraphs(1).Range.Select
oWord.Selection.MoveRight
oWord.Selection.Fields.Add Range:=oWord.Selection.Range,
Type:=wdFieldDate
End Sub
The last line will get runtime problem. why?
Sub Macro1()
'Using default paragraphs(1)
ActiveDocument.Paragraphs(1).Range.Text = "Date:"
ActiveDocument.Paragraphs(1).Range.Select
Selection.MoveRight
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldDate
End Sub
These codes work fine
Now we check how this work in excel(version 2003)
Private Sub CommandButton1_Click()
Dim oWord As Object
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Documents.Add
Set CurrentDoc = oWord.Documents(1)
CurrentDoc.Paragraphs(1).Range.Text = "Date:"
CurrentDoc.Paragraphs(1).Range.Select
oWord.Selection.MoveRight
oWord.Selection.Fields.Add Range:=oWord.Selection.Range,
Type:=wdFieldDate
End Sub
The last line will get runtime problem. why?