• Export Table từ access sang 1 file word có sẵn!
  • Export Table từ access sang 1 file word có sẵn!

    chatchut > 24-03-12, 12:13 PM

    Cho em hỏi thêm chút:
    nhập một thông tin nhưng muốn hiển thị ở 2 file word khác nhau thì khai báo làm sao?
    Anh chị giúp em với
  • RE: Export Table từ access sang 1 file word có sẵn!

    quanghoasla > 24-03-12, 01:21 PM

    mình có một cách hay hơn. đó là dùng cách dùng automarcro trong ms word bạn ạ. mình đã làm 1 chương trình quản lý hộ tịch cho bạn mình. chạy ok luôn. Bạn biết cách tạo macro trong ms word chưa? việc đầu tiên là bạn phải sử dụng 1 data table ở ms access hoặc ms excel cũng được. ko quan trọng vì nó chỉ làm table chứa dữ liệu thôi. cái thứ 2 là bạn phải có 1 form để trộn. cái thứ 3 bạn tạo 1 macro trong ms word sau đó mở ra bằng nhấn tổ hợp phìm all+ F11 nó hiện ra bạn copy doạn code đó dán vào 1 cmdbutton trên form. dán nó vào sự kiện onclick() đó. lúc nào bạn muốn trộn thì chỉ cần ấn nút đó là giải quyết vấn đề xong xuôi thôi. chúc bạn vui vẻ
  • RE: Export Table từ access sang 1 file word có sẵn!

    chatchut > 24-03-12, 08:43 PM

    theo ý của em thì: em nhập thông tin cá nhân sau đó in hai 2 file word cùng sử dụng thông tin này
    người dử dụng chỉ cần nhập thông tin và ấn in thì sẽ in chứ không phải thao tác nhiều.

  • RE: Export Table từ access sang 1 file word có sẵn!

    domfootwear > 26-03-12, 09:38 AM

    (24-03-12, 12:13 PM)chatchut Đã viết: Cho em hỏi thêm chút:
    nhập một thông tin nhưng muốn hiển thị ở 2 file word khác nhau thì khai báo làm sao?
    Anh chị giúp em với

    Tạo thêm 1 file Word dạng Temp. giống như file word trước đó có tên là Doc1.dot, hay là tên gì đó tùy bạn, ở đây tôi đặt tên cho nó là Doc1.dot.
    Code sẽ như sau:
    Mã PHP:
    Private Sub Command0_Click()
    Dim oApp As Objectdoc As Object
    Dim strDocName 
    As String

    Set oApp 
    CreateObject("Word.Application")
    oApp.Visible True
    'Xuat sang file word 1
        strDocName = CurrentProject.Path & "\doc.dot"
        Set doc = oApp.Documents.Add(strDocName)
        doc.FormFields("Text1").Result = Me.Text1
    '
    Xuat sang file word 2
        strDocName 
    CurrentProject.Path "\doc1.dot"
        
    Set doc oApp.Documents.Add(strDocName)
        
    doc.FormFields("Text1").Result Me.Text1

    Set oApp 
    Nothing
    End Sub 
    Bạn xem thêm file đính kèm nhé (Nhớ giải nén rồi mới mở file nhé)
  • RE: Export Table từ access sang 1 file word có sẵn!

    chatchut > 26-03-12, 09:37 PM

    Cám ơn domfootwear nhiều
    em sẽ thử vào chương trình của em
    Cho em hỏi thêm với: em không muốn mở file word khi chọn xuất sang word temp mà muốn tạo nút in
    để chọn in:
    vd: muốn in file "doc" thì chọn nút "doc"
    muốn in file "doc1" thì chon nút "doc1"
    Rất mong domfootwear hướng dẫn thêm cho em
  • RE: Export Table từ access sang 1 file word có sẵn!

    chatchut > 28-03-12, 09:33 PM

    (26-03-12, 09:37 PM)chatchut Đã viết: Cám ơn domfootwear nhiều
    em sẽ thử vào chương trình của em
    Cho em hỏi thêm với: em không muốn mở file word khi chọn xuất sang word temp mà muốn tạo nút in
    để chọn in:
    vd: muốn in file "doc" thì chọn nút "doc"
    muốn in file "doc1" thì chon nút "doc1"
    Rất mong domfootwear hướng dẫn thêm cho em

    Anh, Chị giúp em với
  • RE: Export Table từ access sang 1 file word có sẵn!

    domfootwear > 29-03-12, 03:14 PM

    (26-03-12, 09:37 PM)chatchut Đã viết: Cám ơn domfootwear nhiều
    em sẽ thử vào chương trình của em
    Cho em hỏi thêm với: em không muốn mở file word khi chọn xuất sang word temp mà muốn tạo nút in
    để chọn in:
    vd: muốn in file "doc" thì chọn nút "doc"
    muốn in file "doc1" thì chon nút "doc1"
    Rất mong domfootwear hướng dẫn thêm cho em

    Làm luôn cho bạn các tùy chọn để xuất, in file doc và doc1 luôn.

    Mã PHP:
    Private Sub Command0_Click()
    Dim oApp As Objectdoc As Object
    Dim strDocName 
    As String

    Select 
    Case frDK.Value
    Case 1
    'Xuat sang file word 1 va in
       Set oApp = CreateObject("Word.Application")
       oApp.Visible = False
     
        strDocName = CurrentProject.Path & "\doc.dot"
        Set doc = oApp.Documents.Add(strDocName)
        doc.FormFields("Text1").Result = Me.Text1
        doc.PrintOut
        oApp.Quit (False)
    Case 2
    '
    Xuat sang file word 2 va in
        Set oApp 
    CreateObject("Word.Application")
        
    oApp.Visible True
        strDocName 
    CurrentProject.Path "\doc1.dot"
        
    Set doc oApp.Documents.Add(strDocName)
        
    doc.FormFields("Text1").Result Me.Text1
        doc
    .PrintOut
        oApp
    .Quit (False)

    Case 
    3
    'Xuat sang file word 1
       Set oApp = CreateObject("Word.Application")
       oApp.Visible = True
     
        strDocName = CurrentProject.Path & "\doc.dot"
        Set doc = oApp.Documents.Add(strDocName)
        doc.FormFields("Text1").Result = Me.Text1
    Case 4
    '
    Xuat sang file word 2
        Set oApp 
    CreateObject("Word.Application")
        
    oApp.Visible True
        strDocName 
    CurrentProject.Path "\doc1.dot"
        
    Set doc oApp.Documents.Add(strDocName)
        
    doc.FormFields("Text1").Result Me.Text1

    End Select
    Set oApp 
    Nothing
    End Sub 
    Bạn xem file đính kèm nhé.
  • RE: Export Table từ access sang 1 file word có sẵn!

    kia194 > 31-03-12, 09:11 AM

    Cake:
  • RE: Export Table từ access sang 1 file word có sẵn!

    thanhphongialy > 27-04-12, 12:22 PM

    (26-03-12, 09:38 AM)domfootwear Đã viết:
    (24-03-12, 12:13 PM)chatchut Đã viết: Cho em hỏi thêm chút:
    nhập một thông tin nhưng muốn hiển thị ở 2 file word khác nhau thì khai báo làm sao?
    Anh chị giúp em với

    Tạo thêm 1 file Word dạng Temp. giống như file word trước đó có tên là Doc1.dot, hay là tên gì đó tùy bạn, ở đây tôi đặt tên cho nó là Doc1.dot.
    Code sẽ như sau:
    Mã PHP:
    Private Sub Command0_Click()
    Dim oApp As Objectdoc As Object
    Dim strDocName 
    As String

    Set oApp 
    CreateObject("Word.Application")
    oApp.Visible True
    'Xuat sang file word 1
        strDocName = CurrentProject.Path & "\doc.dot"
        Set doc = oApp.Documents.Add(strDocName)
        doc.FormFields("Text1").Result = Me.Text1
    '
    Xuat sang file word 2
        strDocName 
    CurrentProject.Path "\doc1.dot"
        
    Set doc oApp.Documents.Add(strDocName)
        
    doc.FormFields("Text1").Result Me.Text1

    Set oApp 
    Nothing
    End Sub 
    Bạn xem thêm file đính kèm nhé (Nhớ giải nén rồi mới mở file nhé)

    Cảm ơn bác đã chỉ giáo! Xin hỏi thêm 1 vấn đề:
    Có cách nào khi e ấn "in" thì file word đó in ra và tự động lưu với 1 tên được lấy từ 1 ô trên table từ acces không?
    Chân thành cảm ơn!
  • RE: Export Table từ access sang 1 file word có sẵn!

    domfootwear > 27-04-12, 01:55 PM

    (27-04-12, 12:22 PM)thanhphongialy Đã viết: Cảm ơn bác đã chỉ giáo! Xin hỏi thêm 1 vấn đề:
    Có cách nào khi e ấn "in" thì file word đó in ra và tự động lưu với 1 tên được lấy từ 1 ô trên table từ acces không?
    Chân thành cảm ơn!

    Lưu tên trong Table?
    Thôi tôi làm thử là khi in cho nó lưu file đó chung với folder chứa file access của bạn. tên file được lấy như sau: "doc " & ddmmmyy hhss. Dĩ nhiên là bạn phải vẽ 1 textbox có tên là txtTen để chứa nội dung tên file.
    Code sẽ như sau:

    Mã PHP:
    Option Compare Database

    Private Sub Command0_Click()
    Dim oApp As Objectdoc As Object
    Dim strDocName 
    As String

    Select 
    Case frDK.Value
    Case 1
    'Xuat sang file word 1 va in
       Set oApp = CreateObject("Word.Application")
       oApp.Visible = False
     
        strDocName = CurrentProject.Path & "\doc.dot"
        Set doc = oApp.Documents.Add(strDocName)
        doc.FormFields("Text1").Result = Me.Text1
        doc.PrintOut
        oApp.ActiveDocument.SaveAs Filename:=CurrentProject.Path & "\" & txtTen & ".doc"
        oApp.Quit (True)
    Case 2
    '
    Xuat sang file word 2 va in
        Set oApp 
    CreateObject("Word.Application")
        
    oApp.Visible False
        strDocName 
    CurrentProject.Path "\doc1.dot"
        
    Set doc oApp.Documents.Add(strDocName)
        
    doc.FormFields("Text1").Result Me.Text1
        doc
    .PrintOut
        oApp
    .ActiveDocument.SaveAs Filename:=CurrentProject.Path "\" & txtTen & ".doc"
        oApp.Quit (True)

    Case 3
    'Xuat sang file word 1
       Set oApp = CreateObject("
    Word.Application")
       oApp.Visible = True
     
        strDocName = CurrentProject.Path & "
    \doc.dot"
        Set doc = oApp.Documents.Add(strDocName)
        doc.FormFields("
    Text1").Result = Me.Text1
    Case 4
    'Xuat sang file word 2
        Set oApp = CreateObject("
    Word.Application")
        oApp.Visible = True
        strDocName = CurrentProject.Path & "
    \doc1.dot"
        Set doc = oApp.Documents.Add(strDocName)
        doc.FormFields("
    Text1").Result = Me.Text1

    End Select
    Set oApp = Nothing
    End Sub

    Private Sub Form_Load()
    Text1 = "
    Noi dung nay se duoc xuat sang Word !!!"
    txtTen = "
    doc " & Format(Now(), "ddmmmyy hhss")
    End Sub


    Private Sub frDK_Click()
    txtTen = "
    doc " & Format(Now(), "ddmmmyy hhss")
    End Sub 

    Bạn xem thêm file nhé
    Thân mến.