Results 1 to 5 of 5

Thread: MS Word Password Question

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    Hi.

    If I know the password of a MSWORD document that has open password, can I open it thru VB code or not?


    Anybody know?

    Thanks
    Wengang
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  2. #2
    Addicted Member
    Join Date
    Oct 2000
    Location
    Vienna/Austria
    Posts
    132

    Cool

    Hi wengang !!!

    Taken von Word 97 Help file

    Syntax

    documents.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format)


    PasswordDocument
    Variant optional. Password to open the Document.
    e.g.
    documents.open Filename:="c:\mydoc.doc",PasswordDocument:="MyPassword"

    -cu TheOnly

  3. #3

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    Hey TheOnly,

    Thanks. but one question.. I have no idea what your code means or how to use it. Can you explain a bit more?
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  4. #4
    Addicted Member
    Join Date
    Oct 2000
    Location
    Vienna/Austria
    Posts
    132
    Hi wengang!!!

    There is a little example below. (tested with vb6 and w2000)
    If you need this in Word then reply to this tread.

    -cu TheOnly



    'set a references to MS word
    'Menuitem Project--> references

    'declare objWord as word
    Dim objWord As Word.Application
    'create a new instance of word
    Set objWord = New Word.Application

    'with Word
    With objWord
    'make Word Window visible
    .Visible = True
    'open the password proteced Document
    .Documents.Open FileName:="c:\pwd.doc", PasswordDocument:="MyPassword"
    End With

    'place your code here what ever you want


    'this will close all documents
    'only for testing I want that nothing will be saved
    'note you can also close only 1 Documente
    objWord.Documents.Close savechanges:=False
    'close Word
    objWord.Quit
    'set the reference to nothing
    Set objWord = Nothing

  5. #5

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    you are the coolest!
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width