creat word field in Excel CommandButton1_Click Macro

J

Julian

ÏÈ¿´ÔÚwordÖеÄÒ»¸öºê£º

Sub Macro1()
'н¨Ò»¸ö¿Õ°×Îĵµ£¬ÀïÃæĬÈÏÓÐ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

ÒÔÉÏ´úÂëÓÃÓò²åÈëÁËÈÕÆÚ£¬Ã»ÓÐÎÊÌâ

ÔÙ¿´ÔÚExcelÖеÄʵÏÖͬÑù¹¦Äܵĺ꣺

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

Õâ¸öºêÖ´Ðе½µ¹ÊýµÚ¶þÐж¼Ã»ÎÊÌ⣬¾Í×îºóÒ»¾äÌáʾ¡°ÔËÐÐʱ´íÎó'4068',Ó¦ÓóÌÐò¶¨Òå»ò¶ÔÏó¶¨Òå´íÎ󡱡£
¼±Çó½â£¡
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top