Lm th? no ? s? d?ng t? ?ng ha ? c ?c v ?t thu?c tnh ti li?u vn ph?ng v?i Visual Basic.NET

D?ch tiu ? D?ch tiu ?
ID c?a bi: 303294 - Xem s?n ph?m m bi ny p d?ng vo.
Bung t?t c? | Thu g?n t?t c?

TM T?T

Bi vi?t ny minh ho? lm th? no ? t? ?ng ho Microsoft Word v?i Microsoft Visual C b?n.NET ? l?y v thao tc thu?c tnh ti li?u. M?c d cc m?u trong bi vi?t ny c? th? ?c vi?t ? t? ?ng t?, cng m?t khi ni?m c th? ?c p d?ng cho Microsoft Excel v Microsoft PowerPoint.

THNG TIN THM

T?o ra m?t khch hng t? ?ng ha cho Microsoft Word

  1. B?t ?u Visual Studio.NET.
  2. Trn cc Tp tr?nh n, nh?p vo M?i, sau b?m D an. Ch?n ?ng d?ng Windows t? cc lo?i d? n Visual Basic. Form1 ?c t?o ra b?ng m?c ?nh.
  3. Thm m?t tham chi?u ?n Microsoft Word ?i t?ng th vi?n. thc hin vic nay, hay lam theo nhng bc sau:
    1. Trn cc D an tr?nh n, nh?p vo Thm ti li?u tham kh?o.
    2. Trn cc COM tab, xc ?nh v? tr cc Microsoft Word ?i t?ng th vi?n, sau b?m Ch?n.

      Chu y Microsoft Office 2003 bao g?m chnh Interop h?i ?ng (PIAs). Microsoft Office XP khng bao g?m PIAs, nhng h? c th? ?c t?i v?.? bi?t thm chi ti?t v? Office XP PIAs, nh?p vo s? bi vi?t sau y ? xem bi vi?t trong c s? ki?n th?c Microsoft:
      328912Microsoft Office XP chnh interop h?i ?ng (PIAs) c s?n ? t?i v?
    3. Nh?p vo Ok trong cc Thm ti li?u tham kh?o h?p tho?i ? ch?p nh?n c?a b?n l?a ch?n. N?u b?n ?c nh?c t?o ra hm bao cho cc th vi?n m b?n ? ch?n, b?m vo Co.
  4. Trn cc Xem tr?nh n, ch?n H?p cng c? hi?n th? h?p cng c?, v thm m?t nt vo Form1.
  5. B?m p Button1. C?a s? m? cho cc h?nh th?c xu?t hi?n.
  6. Trong c?a s? m?, thay th? m? sau
    Private Sub Button1_Click(ByVal sender As System.Object, _
                              ByVal e As System.EventArgs) _
                              Handles Button1.Click
    End Sub
    					
    v?i:
    Private Sub Button1_Click(ByVal sender As System.Object, _
                              ByVal e As System.EventArgs) _
                              Handles Button1.Click
            Dim oWord As Word.Application
            Dim oDoc As Word.Document
            Dim oBuiltInProps As Object
            Dim oCustomProps As Object
            Dim oProp As Object
            Dim strValue As String
    
            'Create an instance of Word and make it visible.
            oWord = CreateObject("Word.Application")
            oWord.Visible = True
            'Create a new document
            oDoc = oWord.Documents.Add()
    
            'Get the Built-in Document Properties collection.
            oBuiltInProps = oDoc.BuiltInDocumentProperties
            'Get the value of the Author property and display it
            strValue = oBuiltInProps.Item("Author").Value
            MsgBox("The author of this document is " & strValue)        
    
            'Set the value of the Subject property.
            oBuiltInProps.Item("Subject").Value = _
                      "Knowledge Base article Q303294"
    
            'Get the Custom Document Properties collection.
            oCustomProps = oDoc.CustomDocumentProperties
            'Add a property named Knowledge Base Article
            'and give it a value of Q303294.
            oCustomProps.Add("Knowledge Base article", False, _
                      Office.MsoDocProperties.msoPropertyTypeString, "Q303294")
    
            'Display a message box to give the user a chance to verify the
            'properties.
            MsgBox("Select Properties from the File menu " _
                   & "to view the changes." & Chr(10) _
                   & "Select the Summary tab to view " _
                   & "the Subject and the Custom tab to view the Custom " _
                   & "properties.", MsgBoxStyle.Information, _
                   "Check File Properties")
    
            'Clean up. We'll leave Word running.
            oCustomProps = Nothing
            oBuiltInProps = Nothing
            oDoc = Nothing
            oWord = Nothing
    
        End Sub 
    					
  7. Thm m? sau vo pha trn c?a Form1.vb:
    Imports Office = Microsoft.Office.Core
    Imports Word = Microsoft.Office.Interop.Word
  8. Nh?n F5 ? ch?y cc ?ng d?ng.
  9. Nh?p vo Button1 ? b?t ?u Microsoft Word.
M? ny ch?ng t? ?c v vi?t c? hai thu?c tnh ?c xy d?ng trong ti li?u v thu?c tnh ty ch?nh ti li?u. Khi ch?y, m? ny s? hi?n th? gi tr? c?a built-in Tc gi? b?t ?ng s?n, thay ?i cc Ch? ? b?t ?ng s?n c gi tr? ? "Bi vi?t c s? ki?n th?c Q303294", v t?o ra m?t b?t ?ng s?n ty ch?nh ti li?u m?i ?c ?t tn "Bi vi?t c s? ki?n th?c." Khi b?n ang nh?c nh? ? xem cc thay ?i, chuy?n sang Word v nh?p vo Thu?c tnh trn cc Tp tr?nh n.

THAM KH?O

? bi?t thm chi ti?t, truy c?p vo cc nh pht tri?n Microsoft sau y Trang Web m?ng:
Vn ph?ng Microsoft pht tri?n v?i Visual Studio
http://msdn2.Microsoft.com/en-US/Library/aa188489 (office.10) .aspx
? bi?t thm thng tin, h?y b?m vao s? bi vi?t sau ? xem bi vi?t trong C s? Ki?n th?c Microsoft:
303296Lm th? no ? s? d?ng t? ?ng ha ? l?y v ?t thu?c tnh ti li?u vn ph?ng v?i Visual C#.NET

Thu?c tnh

ID c?a bi: 303294 - L?n xem xt sau cng: 26 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
  • Microsoft Excel 2002 Standard Edition
  • Microsoft Office PowerPoint 2003
  • Microsoft PowerPoint 2002 Standard Edition
  • Microsoft Word 2002 Standard Edition
T? kha:
kbpia kbautomation kbhowto kbmt KB303294 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:303294

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com