Ir ao conteúdo
  • Cadastre-se

Tecla enter pula para a próxima linha em um documento de formulário protegido por sen


gilcom1

Posts recomendados

Boa noite.

Trabalho com processos onde somente alguns itens são modificados, fiz no word 2003 os documentos e coloquei os campos do formulário conforme condiz com as minhas necessidades, ficou lindo e prático não exigindo de mim e nem muitas habilidades afinal ele faz conforme programado, mas o problema está quando aperto a tecla enter, ele cria uma linha abaixo do documento e não converte para o que foi programado, somente a tecla tab converte para o que preciso, mesmo ele protegido por senha e definido como apenas preenchimento de formulário. Mesmo sem entender de VB pesquisei e fiz o seguinte: criei um modulo no documento e digitei

Sub EnterKeyMacro()

' Check whether the document is protected for forms

' and whether the protection is active.

If ActiveDocument.ProtectionType = wdAllowOnlyFormFields And _

Selection.Sections(1).ProtectedForForms = True Then

' Retrieve the bookmark of the current selection.

' This is equivalent to the name of the form field.

myformfield = Selection.Bookmarks(1).Name

' Go to the next form field if the current form field

' is not the last one in the document.

If ActiveDocument.FormFields(myformfield).Name <> _

ActiveDocument.FormFields(ActiveDocument.FormFields.Count) _

.Name Then

ActiveDocument.FormFields(myformfield).Next.Select

Else

' If the current form field is the last one,

' go to the first form field in the document.

ActiveDocument.FormFields(1).Select

End If

Else

' If the document is not protected for forms,

' insert a tab stop character.

Selection.TypeText Chr(13)

End If

End Sub

fui no ThisDocument e copiei

Sub AutoNew()

' Do Not protect the template containing these macros.

CustomizationContext = ActiveDocument.AttachedTemplate

' Bind the ENTER key to the EnterKeyMacro.

KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _

KeyCategory:=wdKeyCategoryMacro, Command:="EnterKeyMacro"

' Reprotect the document with Forms protection.

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

End Sub

Sub AutoOpen()

' This macro will reassign the ENTER key when you open an existing

' Word form fields document.

CustomizationContext = ActiveDocument.AttachedTemplate

' Bind the Enter key to the EnterKeyMacro.

KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _

KeyCategory:=wdKeyCategoryMacro, Command:="EnterKeyMacro"

End Sub

Sub AutoClose()

CustomizationContext = ActiveDocument.AttachedTemplate

FindKey(KeyCode:=BuildKeyCode(wdKeyReturn)).Disable

' Disables prompt to save template changes.

Templates(1).Save

End Sub

mas não resolveu meu problema afinal ele somente pula de um formulário para o outro sem fazer a modificação que preciso, e para que foi programada.

Se alguém puder me ajudar agradeço.

Gil:confused:

Link para o comentário
Compartilhar em outros sites

consegui descobrir vou postar a resposta para caso alguém precise esteja ai a solução.

para que o enter funcione igual ao tab é só excluir

' Retrieve the bookmark of the current selection.

' This is equivalent to the name of the form field.

myformfield = Selection.Bookmarks(1).Name

' Go to the next form field if the current form field

' is not the last one in the document.

If ActiveDocument.FormFields(myformfield).Name <> _

ActiveDocument.FormFields(ActiveDocument.FormField s.Count) _

.Name Then

ActiveDocument.FormFields(myformfield).Next.Select

Else

' If the current form field is the last one,

' go to the first form field in the document.

ActiveDocument.FormFields(1).Select

End If

e substituir por

'Sendkeys "{tab}"

caso não queira que a tecla enter funcione é digitar

Sub EnterKeyMacro()

End Sub

agradeço aos que tentaram me ajudar

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!