PC Review


Reply
Thread Tools Rate Thread

How to assign password for output to command

 
 
Tim
Guest
Posts: n/a
 
      13th Sep 2003
Hi guys,

I currently using the following command to output my
report.

DoCmd.OutputTo acReport, "TableB", "RichTextFormat
(*.rtf)", "c:\temp\test.doc", False, ""

Is it possible to add password to "c:\temp\test.doc"?

Thanks in advance.

Tim.
 
Reply With Quote
 
 
 
 
TC
Guest
Posts: n/a
 
      13th Sep 2003
You would have to do this by starting an instance of Word, then using Word
VBA commands to open the document & establish the password.

Something like this (untested):

dim oWord as object
set oWord = createobject ("word.application")
oWord.visible = true
oWord.open "C:\temp\test.doc"
[ set password here ]
oWord.close
oWord.quit
set oWord = nothing

Look at the Word VBA help to find the appropriate Word VBA command(s) to set
the password.

HTH,
TC


"Tim" <(E-Mail Removed)> wrote in message
news:074b01c3799a$31ce3d30$(E-Mail Removed)...
> Hi guys,
>
> I currently using the following command to output my
> report.
>
> DoCmd.OutputTo acReport, "TableB", "RichTextFormat
> (*.rtf)", "c:\temp\test.doc", False, ""
>
> Is it possible to add password to "c:\temp\test.doc"?
>
> Thanks in advance.
>
> Tim.



 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      14th Sep 2003
Hi TC,

Thanks you for your response. I tried the code but I
couldn't figure how to add the password. Could you help
me again?

Public Sub test()

Dim oWord As Object

set oWord = createobject ("word.application")
oWord.Visible = true
oWord.Documents.open "C:\temp\test.doc"
'How To Add password

oWord.ActiveDocment.Close
oWord.Quit
set oWord = Nothing

End Sub

Thanks.

Tim.


>-----Original Message-----
>You would have to do this by starting an instance of

Word, then using Word
>VBA commands to open the document & establish the

password.
>
>Something like this (untested):
>
>dim oWord as object
>set oWord = createobject ("word.application")
>oWord.visible = true
>oWord.open "C:\temp\test.doc"
>[ set password here ]
>oWord.close
>oWord.quit
>set oWord = nothing
>
>Look at the Word VBA help to find the appropriate Word

VBA command(s) to set
>the password.
>
>HTH,
>TC
>
>
>"Tim" <(E-Mail Removed)> wrote in message
>news:074b01c3799a$31ce3d30$(E-Mail Removed)...
>> Hi guys,
>>
>> I currently using the following command to output my
>> report.
>>
>> DoCmd.OutputTo acReport, "TableB", "RichTextFormat
>> (*.rtf)", "c:\temp\test.doc", False, ""
>>
>> Is it possible to add password to "c:\temp\test.doc"?
>>
>> Thanks in advance.
>>
>> Tim.

>
>
>.
>

 
Reply With Quote
 
TC
Guest
Posts: n/a
 
      14th Sep 2003

I don't have Word on this PC, to check.

However, you might try this at the line in question:

oWord.ActiveDocument.Password = "645bn&#$z!" ' <- the password.

HTH,
TC


"Tim" <(E-Mail Removed)> wrote in message
news:004001c37a6e$8bbc71c0$(E-Mail Removed)...
> Hi TC,
>
> Thanks you for your response. I tried the code but I
> couldn't figure how to add the password. Could you help
> me again?
>
> Public Sub test()
>
> Dim oWord As Object
>
> set oWord = createobject ("word.application")
> oWord.Visible = true
> oWord.Documents.open "C:\temp\test.doc"
> 'How To Add password
>
> oWord.ActiveDocment.Close
> oWord.Quit
> set oWord = Nothing
>
> End Sub
>
> Thanks.
>
> Tim.
>
>
> >-----Original Message-----
> >You would have to do this by starting an instance of

> Word, then using Word
> >VBA commands to open the document & establish the

> password.
> >
> >Something like this (untested):
> >
> >dim oWord as object
> >set oWord = createobject ("word.application")
> >oWord.visible = true
> >oWord.open "C:\temp\test.doc"
> >[ set password here ]
> >oWord.close
> >oWord.quit
> >set oWord = nothing
> >
> >Look at the Word VBA help to find the appropriate Word

> VBA command(s) to set
> >the password.
> >
> >HTH,
> >TC
> >
> >
> >"Tim" <(E-Mail Removed)> wrote in message
> >news:074b01c3799a$31ce3d30$(E-Mail Removed)...
> >> Hi guys,
> >>
> >> I currently using the following command to output my
> >> report.
> >>
> >> DoCmd.OutputTo acReport, "TableB", "RichTextFormat
> >> (*.rtf)", "c:\temp\test.doc", False, ""
> >>
> >> Is it possible to add password to "c:\temp\test.doc"?
> >>
> >> Thanks in advance.
> >>
> >> Tim.

> >
> >
> >.
> >



 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      14th Sep 2003
Hi TC,

I tried the command but it doesn't work.

Thanks for your time.

Tim.
>-----Original Message-----
>
>I don't have Word on this PC, to check.
>
>However, you might try this at the line in question:
>
> oWord.ActiveDocument.Password = "645bn&#$z!" ' <- the

password.
>
>HTH,
>TC
>
>
>"Tim" <(E-Mail Removed)> wrote in message
>news:004001c37a6e$8bbc71c0$(E-Mail Removed)...
>> Hi TC,
>>
>> Thanks you for your response. I tried the code but I
>> couldn't figure how to add the password. Could you help
>> me again?
>>
>> Public Sub test()
>>
>> Dim oWord As Object
>>
>> set oWord = createobject ("word.application")
>> oWord.Visible = true
>> oWord.Documents.open "C:\temp\test.doc"
>> 'How To Add password
>>
>> oWord.ActiveDocment.Close
>> oWord.Quit
>> set oWord = Nothing
>>
>> End Sub
>>
>> Thanks.
>>
>> Tim.
>>
>>
>> >-----Original Message-----
>> >You would have to do this by starting an instance of

>> Word, then using Word
>> >VBA commands to open the document & establish the

>> password.
>> >
>> >Something like this (untested):
>> >
>> >dim oWord as object
>> >set oWord = createobject ("word.application")
>> >oWord.visible = true
>> >oWord.open "C:\temp\test.doc"
>> >[ set password here ]
>> >oWord.close
>> >oWord.quit
>> >set oWord = nothing
>> >
>> >Look at the Word VBA help to find the appropriate Word

>> VBA command(s) to set
>> >the password.
>> >
>> >HTH,
>> >TC
>> >
>> >
>> >"Tim" <(E-Mail Removed)> wrote in message
>> >news:074b01c3799a$31ce3d30$(E-Mail Removed)...
>> >> Hi guys,
>> >>
>> >> I currently using the following command to output my
>> >> report.
>> >>
>> >> DoCmd.OutputTo acReport, "TableB", "RichTextFormat
>> >> (*.rtf)", "c:\temp\test.doc", False, ""
>> >>
>> >> Is it possible to add password to "c:\temp\test.doc"?
>> >>
>> >> Thanks in advance.
>> >>
>> >> Tim.
>> >
>> >
>> >.
>> >

>
>
>.
>

 
Reply With Quote
 
Tim Ferguson
Guest
Posts: n/a
 
      14th Sep 2003
PMFJI

"Tim" <(E-Mail Removed)> wrote in
news:027701c37ac8$219a15e0$(E-Mail Removed):

>>
>>I don't have Word on this PC, to check.
>>
>>However, you might try this at the line in question:
>>
>> oWord.ActiveDocument.Password = "645bn&#$z!" ' <- the
>> ' password.

> I tried the command but it doesn't work.
>
>

This is from Word help on the Open method:

Syntax 1

expression.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles,
PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument,
WritePasswordTemplate, Format, Encoding, Visible)

....

PasswordDocument Optional Variant. The password for opening the document.

PasswordTemplate Optional Variant. The password for opening the template.


Hope that helps


Tim F



 
Reply With Quote
 
TC
Guest
Posts: n/a
 
      15th Sep 2003

FFTJIWUL!

But, he wants to *add* a password to his files. Your syntax is for opening a
file with an existing password.

To the original poster: what do you mean, "it doesn't work"? What error
message did you get?

TC

FFTJIWUL: feel free to jump in whenever you like!



"Tim Ferguson" <(E-Mail Removed)> wrote in message
news:Xns93F6ACD95D65garbleme4455656@207.46.248.16...
> PMFJI
>
> "Tim" <(E-Mail Removed)> wrote in
> news:027701c37ac8$219a15e0$(E-Mail Removed):
>
> >>
> >>I don't have Word on this PC, to check.
> >>
> >>However, you might try this at the line in question:
> >>
> >> oWord.ActiveDocument.Password = "645bn&#$z!" ' <- the
> >> ' password.

> > I tried the command but it doesn't work.
> >
> >

> This is from Word help on the Open method:
>
> Syntax 1
>
> expression.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles,
> PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument,
> WritePasswordTemplate, Format, Encoding, Visible)
>
> ...
>
> PasswordDocument Optional Variant. The password for opening the

document.
>
> PasswordTemplate Optional Variant. The password for opening the

template.
>
>
> Hope that helps
>
>
> Tim F




 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      15th Sep 2003
Hi TC,

I didn't get any error message. The code didn't add the
password to my file.

Thanks.

Tim.

>-----Original Message-----
>
>FFTJIWUL!
>
>But, he wants to *add* a password to his files. Your

syntax is for opening a
>file with an existing password.
>
>To the original poster: what do you mean, "it doesn't

work"? What error
>message did you get?
>
>TC
>
>FFTJIWUL: feel free to jump in whenever you like!
>
>
>
>"Tim Ferguson" <(E-Mail Removed)> wrote in message
>news:Xns93F6ACD95D65garbleme4455656@207.46.248.16...
>> PMFJI
>>
>> "Tim" <(E-Mail Removed)> wrote in
>> news:027701c37ac8$219a15e0$(E-Mail Removed):
>>
>> >>
>> >>I don't have Word on this PC, to check.
>> >>
>> >>However, you might try this at the line in question:
>> >>
>> >> oWord.ActiveDocument.Password = "645bn&#$z!" ' <-

the
>> >> '

password.
>> > I tried the command but it doesn't work.
>> >
>> >

>> This is from Word help on the Open method:
>>
>> Syntax 1
>>
>> expression.Open(FileName, ConfirmConversions, ReadOnly,

AddToRecentFiles,
>> PasswordDocument, PasswordTemplate, Revert,

WritePasswordDocument,
>> WritePasswordTemplate, Format, Encoding, Visible)
>>
>> ...
>>
>> PasswordDocument Optional Variant. The password for

opening the
>document.
>>
>> PasswordTemplate Optional Variant. The password for

opening the
>template.
>>
>>
>> Hope that helps
>>
>>
>> Tim F

>
>
>
>.
>

 
Reply With Quote
 
Tim Ferguson
Guest
Posts: n/a
 
      15th Sep 2003
"TC" <(E-Mail Removed)> wrote in news:1063616490.204868@teuthos:

>
> FFTJIWUL!


Okay, I give up -- what does that mean?

> But, he wants to *add* a password to his files. Your syntax is for
> opening a file with an existing password.


Speedreading again..., try the SaveAs method:

Saves the specified document with a new name or format. The arguments for
this method correspond to the options in the Save As dialog box (File
menu).

Syntax

expression.SaveAs(FileName, FileFormat, LockComments, Password,
AddToRecentFiles, WritePassword, ReadOnlyRecommended, EmbedTrueTypeFonts,
SaveNativePictureFormat, SaveFormsData, SaveAsAOCELetter)

....

Password Optional Variant. A password string for opening the document.


Have to admit, though, that I didn't know about the Password property until
I just looked it up. Learn something every day... :-)

All the best


Tim F


 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      15th Sep 2003
Tim F

The command line worked, but it didn’t save to c:\temp.
It saved to word’s default folder. Do you know how to
save to c:\temp (My original folder).

Thanks.

Tim.

>-----Original Message-----
>"TC" <(E-Mail Removed)> wrote in news:1063616490.204868@teuthos:
>
>>
>> FFTJIWUL!

>
>Okay, I give up -- what does that mean?
>
>> But, he wants to *add* a password to his files. Your

syntax is for
>> opening a file with an existing password.

>
>Speedreading again..., try the SaveAs method:
>
>Saves the specified document with a new name or format.

The arguments for
>this method correspond to the options in the Save As

dialog box (File
>menu).
>
>Syntax
>
>expression.SaveAs(FileName, FileFormat, LockComments,

Password,
>AddToRecentFiles, WritePassword, ReadOnlyRecommended,

EmbedTrueTypeFonts,
>SaveNativePictureFormat, SaveFormsData, SaveAsAOCELetter)
>
>....
>
>Password Optional Variant. A password string for

opening the document.
>
>
>Have to admit, though, that I didn't know about the

Password property until
>I just looked it up. Learn something every day... :-)
>
>All the best
>
>
>Tim F
>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I can't find the Assign Macro command =?Utf-8?B?RGF2ZQ==?= Microsoft Excel Misc 3 27th Sep 2006 07:08 PM
Assign a macro to a command button =?Utf-8?B?U2hlcmlUaW5nbGU=?= Microsoft Excel Misc 4 25th Sep 2006 06:38 PM
how can I assign a password to a command button =?Utf-8?B?SGVscCE=?= Microsoft Excel Programming 2 4th Jan 2006 01:52 PM
command button and assign macro RichardO Microsoft Excel Programming 3 27th May 2004 03:01 AM
Re: Can't assign macro to command button Ken Macksey Microsoft Excel Misc 0 7th Sep 2003 03:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:51 PM.