VB code to command button for opening, saving and passwording an .rtf from a report
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 270   1
URL.หัวข้อ / URL
VB code to command button for opening, saving and passwording an .rtf from a report

มีคนถามไว้ที่ 
http://board.quicktechusa.com/cgi-bin/ultimatebb.cgi?ubb=reply;f=1;t=001175 
 
คำถามมีดังนี้ 
 
 
I need help with code that will automatically, convert a report into an .rtf and password protect it. 
 
help  
 
"จะเขียนโค้ดอย่างไรให้มีการ convert รายงานให้เป็น *.rtf แล้วใส่ Password ด้วย" 
 
 
เนื่องจากเราจะไม่สามารถใส่ Password ให้ไฟล์ rtf ได้ จึงต้องเปลี่ยนให้เป็น *.doc ก่อน 
 
 
Sub X2Rtf() 
Dim strFileName As String 
Dim objWord As Object, strNum As Integer, strName As String, dblSal As String 
 
strFileName = "c:/test.rtf" 
DoCmd.OutputTo acOutputReport, "rptOral", acFormatRTF, strFileName 
Set objWord = CreateObject("Word.Application") 
     
    With objWord 
        .Visible = False 
        .Documents.Open FileName:=strFileName 
        .ActiveDocument.SaveAs FileName:="c:/test.doc", FileFormat:=0, _ 
        LockComments:=False, Password:="supap", AddToRecentFiles:=True, WritePassword _ 
        :="kaeg", ReadOnlyRecommended:=True, EmbedTrueTypeFonts:=False, _ 
        SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _ 
        False 
    End With 
    MsgBox "Finished" 
    objWord.ActiveDocument.Close 
    ' Quit Word 
    objWord.Quit 
    Set objWord = Nothing 
End Sub 
 
 
ลองดูครับ *** Edited by Supap Chaiya *** 5/6/2003 3:56:06 PM

1 Reply in this Topic. Dispaly 1 pages and you are on page number 1

1 @R06500
   
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.0462s