|
|
|
Как сделать так чтоб созданная на основе шаблона книга была закрыта паролем на именение?
|
|||
|---|---|---|---|
|
#18+
Программно(Delphi, OLE Automation), создаю книгу на основее ранее подготовленного шаблона(*.xlt), заношу(программно) в книгу данные. Далее, пользователь, проверяет данные и сохранет книгу. Как сделать так, чтобы дальнейшее редактирование книги было закрыто паролем. Необходимая функциональность достижима так: В меню Файл выберите команду Сохранить как. Выберите в меню Сервис команду Общие параметры. Введите пароль в поле Пароль для изменения и нажмите кнопку ОК. По запросу введите пароль еще раз для подтверждения. Нажмите кнопку Сохранить. При появлении запроса на замену имеющейся книги нажмите кнопку Да. Но как сделать так, чтобы закрыть изменение книги паролем, после ее первого сохранения, и не парить пользователя необходимостью выполнять выше перечисленные действия? Например все "забить" в шаблон, но как? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.11.2006, 09:21:53 |
|
||
|
Как сделать так чтоб созданная на основе шаблона книга была закрыта паролем на именение?
|
|||
|---|---|---|---|
|
#18+
Добавь в шаблон кнопку с кодом Код: plaintext 1. 2. Saves changes to the sheet (Syntax 1) or workbook (Syntax 2) in a different file. Syntax 1 expression.SaveAs(Filename, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AddToMru, TextCodePage, TextVisualLayout) Syntax 2 expression.SaveAs(Filename, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution, AddToMru, TextCodePage, TextVisualLayout) expression Required. An expression that returns a Chart or Worksheet object (Syntax 1) or a Workbook object (Syntax 2). Filename Optional Variant. A string that indicates the name of the file to be saved. You can include a full path; if you don’t, Microsoft Excel saves the file in the current folder. FileFormat Optional Variant. The file format to use when you save the file. For a list of valid choices, see the FileFormat property. For an existing file, the default format is the last file format specified; for a new file, the default is the format of the version of Excel being used. Password Optional Variant. A case-sensitive string (no more than 15 characters) that indicates the protection password to be given to the file. WriteResPassword Optional Variant. A string that indicates the write-reservation password for this file. If a file is saved with the password and the password isn’t supplied when the file is opened, the file is opened as read-only. ReadOnlyRecommended Optional Variant. True to display a message when the file is opened, recommending that the file be opened as read-only. CreateBackup Optional Variant. True to create a backup file. AccessMode Optional Variant. The workbook access mode. Can be one of the following XlSaveAsAccessMode constants: xlShared (shared list), xlExclusive (exclusive mode), or xlNoChange (don’t change the access mode). If this argument is omitted, the access mode isn’t changed. This argument is ignored if you save a shared list without changing the file name. To change the access mode, use the ExclusiveAccess method. ConflictResolution Optional Variant. Specifies the way change conflicts are resolved if the workbook is a shared list. Can be one of the following XlSaveConflictResolution constants: xlUserResolution (display the conflict-resolution dialog box), xlLocalSessionChanges (automatically accept the local user’s changes), or xlOtherSessionChanges (accept other changes instead of the local user’s changes). If this argument is omitted, the conflict-resolution dialog box is displayed. AddToMru Optional Variant. True to add this workbook to the list of recently used files. The default value is False. TextCodePage Optional Variant. Not used in U.S. English Microsoft Excel. TextVisualLayout Optional Variant. Not used in U.S. English Microsoft Excel. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.11.2006, 09:42:41 |
|
||
|
Как сделать так чтоб созданная на основе шаблона книга была закрыта паролем на именение?
|
|||
|---|---|---|---|
|
#18+
Спасибо. Сам начал "рыть" в эту сторону. В шаблоне обрабатывается событие- Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Static InDlg As Boolean Const Defaultpath = "\\RU\USER\USERS\MARK" If InDlg Then Exit Sub Cancel = True InDlg = True Application.Dialogs(xlDialogSaveAs).Show Defaultpath InDlg = False End Sub Правильно ли я понял? строку Application.Dialogs(xlDialogSaveAs).Show Defaultpath заменяем на Application.Dialogs(xlDialogSaveAs).Show Defaultpath, ,"Pasword", "Pasword1". Вы пишите -Из справки. Подскажите пожалуйста какой справкой пользуетесь. Самостоятельно я смог найти только "Dialog box constant-xlDialogSaveAs; Argument list(s)-document_text, type_num, prot_pwd, backup, write_res_pwd, read_only_rec" и не каких разеснений, это в Справке по Visual Basic, той что поставляется в Excel. В прочем в MSDN сумел найти только тоже самое. Блин и сколько не пытался раньше что нибудь найти и по другим методам, все тоже самое, метод-аргументы, описаний нет. Как пользоватся справкой в подобных случаях? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.11.2006, 10:16:45 |
|
||
|
Как сделать так чтоб созданная на основе шаблона книга была закрыта паролем на именение?
|
|||
|---|---|---|---|
|
#18+
ru_efimСпасибо. Сам начал "рыть" в эту сторону. В шаблоне обрабатывается событие- Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Static InDlg As Boolean Const Defaultpath = "\\RU\USER\USERS\MARK" If InDlg Then Exit Sub Cancel = True InDlg = True Application.Dialogs(xlDialogSaveAs).Show Defaultpath InDlg = False End Sub Правильно ли я понял? строку Application.Dialogs(xlDialogSaveAs).Show Defaultpath заменяем на Application.Dialogs(xlDialogSaveAs).Show Defaultpath, ,"Pasword", "Pasword1". Вы пишите -Из справки. Подскажите пожалуйста какой справкой пользуетесь. Самостоятельно я смог найти только "Dialog box constant-xlDialogSaveAs; Argument list(s)-document_text, type_num, prot_pwd, backup, write_res_pwd, read_only_rec" и не каких разеснений, это в Справке по Visual Basic, той что поставляется в Excel. В прочем в MSDN сумел найти только тоже самое. Блин и сколько не пытался раньше что нибудь найти и по другим методам, все тоже самое, метод-аргументы, описаний нет. Как пользоватся справкой в подобных случаях? Да я той же справкой пользуюсь. Ну еще есть у меня книга "Джона Уокенбаха" Код: plaintext GetSaveAsFilename вот пример Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. через GetSaveAsFilename получаете путь куда надо сохранить и дальше делаете то что Вам надо. кстати, в данном примере, какой бы пароль не ввел юзер, книга сохраниться с паролем "p1" ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.11.2006, 13:10:12 |
|
||
|
|

start [/forum/topic.php?fid=61&msg=34148909&tid=2183883]: |
0ms |
get settings: |
8ms |
get forum list: |
15ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
35ms |
get topic data: |
12ms |
get forum data: |
3ms |
get page messages: |
47ms |
get tp. blocked users: |
2ms |
| others: | 236ms |
| total: | 364ms |

| 0 / 0 |
