
Modul 3
Komponen yang dibutuhkan :
3 tombol Command
Rancanglah seperti tampilan Form berikut:
Properti yang diubah:
a.command1
Name : CMDBukaWord
Caption : &Buka m_i_crosoft word
b.command2
Name : CMDPutusWord
Caption : &Putus Koneksi
c.command3
Name : CMDKeluar
Caption : &Keluar
Source Code :
Option Explicit
Public appword As Word.Application
Public halword As Word.Document
Private Sub CMDKELUAR_Click()
End
End Sub
Private Sub CmdBukaWord_Click()
On Error Resume Next
Set appword = GetObject(, "word.Application")
If Err.Number <> 0 Then
Set appword = CreateObject("word.Application")
End If
Err.Clear
On Error GoTo 0
Set halword = appword.Documents.Open(App.Path & "\data.doc")
End Sub
Private Sub CmdPutusWord_Click()
Set appword = Nothing
Set halword = Nothing
End Sub
Sub Form_Unload(Cancel As Integer)
Set appword = Nothing
Set halword = Nothing
End Sub
Tidak ada komentar:
Posting Komentar