Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unlocking a word file

Status
Not open for further replies.

bluearmy1984

Programmer
Sep 19, 2008
3
GB
I have looked through the forum and can not find a topic for this ,

I have a program that opens a MS word template (.dot file), but one particular file is locked .

Is there any way to unlock / release the file via vb ?

Many thanks in advance .
 

Do you know how to do it manually? Do you have a password?
If so – start Macro recorder in Word and see the code in VBA (Alt-F11)


Have fun.

---- Andy
 
I will normally restore it from a backup folder . I want to do this via VB6 program rather than a macro in Word
 

Well, it is still good to record the macro in VBA in Word, and then you cheat :)

In VB 6 Project, you add the reference to Word object, and in your code in VB 6 you can do this:
Code:
Option Explicit
Dim ObjWord As Word.Application

Private Sub BlahBlahBlah()

With ObjWord
    [blue].Visible = True
    .Documents.Add
    .YourMacroCode    ....[/blue]
    [green]'Any code from your Word Macro[/green]
End With

When you paste your code from your Word macro, make sure that you start every line with the . (dot)

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top