2016-07-20 4 views
0

에너지 회사의 워드 문서 양식을 편집하고 만듭니다. 현장 인사는 필드의 Windows 태블릿에서이 양식을 열 것입니다. Microsoft Word 2010을 사용합니다. 개발자 탭을 사용하여 체크 박스와 날짜 선택 도구 및 기타 기능을 추가하여 태블릿에서 이러한 양식을 빠르고 쉽게 채울 수 있도록했습니다. 그러나 몇 가지 필요성이 있습니다. 코딩 됨.Word VBA - 암호로 보호 된 문서에 버튼이있는 페이지 추가

- 양식은 비밀번호로 보호되며 최종 사용자가 편집 할 수있는 특정 필드 만 있습니다.

- 내 보스는 사용자가 버튼 클릭만으로 문서에 페이지를 추가 할 수있는 옵션을 갖기를 원합니다. 양식 자체는 선호하지만 양식은 비밀번호로 보호되어 있어야합니다. 그는이 추가 페이지가 그들이 수행중인 작업의 사진을 추가하고 품질을 확인하기를 원합니다. 그는 그들이 원하는만큼의 사진 페이지를 추가 할 수 있기를 바란다. 나는 버튼으로 특정 템플릿을 "호출"할 수 있고, 페이지 하단에 버튼을 추가 할 수 있고, 페이지를 채울 때, 그들은 템플릿의 버튼을 클릭하고 프로세스를 반복 할 수 있습니다.)

- 비밀번호로 보호되는이 추가 페이지의 템플릿 페이지를 만들었으며 개발자 탭의 "그림 삽입"필드와 그림 아래에있는 1x1 테이블 중 두 개의 필드가 있습니다.

저는 VBA를 배우고 싶습니다. 누군가 다른 사람의 코드를 복사하여 붙여 넣는 것이 아닙니다. 나는 왜 그것이 작동 하는지를 이해하고 필요에 따라 그것을 만들고 싶다.

나는 html, css 및 javascript로 코딩했습니다 (기본 사항).

+0

문제는 대답하기에는 너무 광범위합니다. 더 작은 조각으로 시작하고 Google을 사용하여 출발점을 찾으십시오. – Chris

답변

0

은 저주와 포럼을 트롤 어업의 며칠 후, 나는이 솔루션을 함께했다, 자신의 프로젝트에 대한이 관심 경우 다른 사람에 여기를 떠나기로 결심 :

개인 서브 PhotoPageTrigger_Click()

'PhotoPage

매크로
ActiveDocument.Unprotect Password:="password" 'unprotect the document with the password 

Selection.GoTo What:=wdGoToBookmark, Name:="\EndofDoc" 'move cursor to the end of the last page 

Selection.TypeParagraph 'insert new paragraph to make a new page 

Selection.Font.Size = 12 'make the new page have a text size of 12 

ChangeFileOpenDirectory _ 
    "I:\FileLocation\" 'Go to this file location 

Documents.Open FileName:= _ 
    "I:\FileLocation\Form Picture Template.docm" _ 
    , ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _ 
    PasswordDocument:="", PasswordTemplate:="", Revert:=False, _ 
    WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _ 
    wdOpenFormatAuto, XMLTransform:="" 'Open this template document and read with these settings 

Selection.GoTo What:=wdGoToBookmark, Name:="\StartofDoc" 'move cursor to the beginning of the document 

Selection.WholeStory 'select all 

Selection.Copy 'copy all 

Selection.GoTo What:=wdGoToBookmark, Name:="\EndofDoc" 'move cursor to home place at the end of the document 

ActiveDocument.Close 'close the open template doc 

Selection.PasteAndFormat (wdUseDestinationStylesRecovery) 'paste contents of clipboard to now-active form doc at the cursor location 

Dim oData As New DataObject 'object to use the clipboard 

oData.SetText Text:=Empty 'Clear the clipboard 
oData.PutInClipboard 

ActiveDocument.Protect Password:="password", NoReset:=False, Type:= _ 
    wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=True 'reprotect document with password and these settings 

최종 하위

내 자신의 모든 일을 만든 꽤 행복! :)

관련 문제