Hello,
I've got this Word doc containing VBA macro and aiming at allowing the user to create any document from the drop-down list in an interface. Now, one of the documents to generate wants page 1 in portrait and the rest in landscape. Any clue how to handle this?
The overall code is as follows:
Private Sub CommandButtonCreate_Click() With ActiveDocument.PageSetup .PaperSize = wdPaperA4 .TopMargin = CentimetersToPoints(2.54) .LeftMargin = CentimetersToPoints(2.54) .RightMargin = CentimetersToPoints(2.54) .BottomMargin = CentimetersToPoints(2.54) End With InsertExistingBuildingBlock 'If ComboBoxDocType.ListIndex = 0 Then 'If Selection.PageSetup.Orientation = 0 Then ' Selection.PageSetup.Orientation = 1 'landscape 'End If 'Else ' Selection.PageSetup.Orientation = 0 'portrait 'End If With ActiveDocument .Bookmarks("EVTBookMarkMarkingHdr").Range.Text = ComboBoxMarking.Value .Bookmarks("EVTBookMarkMarkingFtr").Range.Text = ComboBoxMarking.Value End With Me.Repaint EVT.Hide End SubPrivate Sub userform_initialize() ComboBoxDocType.List = Array("Compilation of Comments", "Lessons Observation", "Military Advice", "Provisional Agenda", "Annotated Agenda", "Letters", "Internal Order", "Notes", "DG EUMS Report") ComboBoxMarking.List = Array("", "LIMITE") 'ListBoxCoC.List = Array("General Comments", "Specific Comments") 'ListBoxMA.List = Array("References", "INTRODUCTION AND AIM", "CONSIDERATIONS", "RECOMMENDATION(S)") 'ListBoxEUMC.List = Array("Adoption of Agenda (ProvAg)", "Adoption of Agenda (OoP)", "Agenda Point (ProvAg)", "Agenda Point (OoP)", "Agenda Point (Possible) (All)", "Information (ProvAg)", "Information (OoP)", "Next Meeting (all)", "AOB @ 28 (All)", "Op. ALTHEA (All)", "AOB @ 27 (All)", "Notes (ProvAg)") 'ComboBoxIOMarking.List = Array("", "LIMITE") ComboBoxSignature.List = Array("DIRECTOR GENERAL", "DEPUTY DIRECTOR GENERAL", "DIRECTOR MPCC", "COS MPCC") ComboBoxAttnOf.List = Array("DIRECTOR GENERAL", "DEPUTY DIRECTOR GENERAL", "Director MPCC", "Chief of Staff MPCC") ComboBoxAim.List = Array("INFORMATION", "DECISION") ComboBoxRecommendation.List = Array("Read ahead of ", "Read by ", "Decision taken by ", "In due course ") 'ListBoxIOOriginator.List = Array("EUMS", "MPCC") ComboBoxIOYear.List = Array("2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030") ComboBoxIONumber.List = Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99") ComboBoxIONumberMPCC.List = Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99") 'ComboBoxLetterMarking.List = Array("", "LIMITE") ComboBoxLetterAuthor.List = Array("DIRECTOR GENERAL", "DEPUTY DIRECTOR GENERAL", "DIRECTOR MPCC", "COS MPCC") ListBoxLetterOriginator.List = Array("", "EUMS", "MPCC") ListBoxIOOriginator.List = Array("EUMS", "MPCC") ListBoxNoteOriginator.List = Array("EUMS", "MPCC") 'ComboBoxNoteMarking.List = Array("", "LIMITE") End Sub
Private Sub ComboBoxLetterAuthor_Change() If ComboBoxLetterAuthor.Value = "DIRECTOR GENERAL" Then TextBoxLetterSignatureName.Value = "Hervé BLEJEAN" TextBoxLetterSignatureRank.Value = "Vice Admiral" End If If ComboBoxLetterAuthor.Value = "DEPUTY DIRECTOR GENERAL" Then TextBoxLetterSignatureName.Value = "Giovanni MANIONE" TextBoxLetterSignatureRank.Value = "Major General" End If 'If ComboBoxLetterAuthor.Value = "DIRECTOR MPCC" Then If ComboBoxLetterAuthor.Value = "DIRECTOR MPCC" Then TextBoxLetterSignatureName.Value = "Hervé BLEJEAN" TextBoxLetterSignatureRank.Value = "Vice Admiral" End If If ComboBoxLetterAuthor.Value = "COS MPCC" Then TextBoxLetterSignatureName.Value = "Herminio MAIO" TextBoxLetterSignatureRank.Value = "Major General" End If End SubPrivate Sub ComboBoxSignature_Change() If ComboBoxSignature.Value = "DIRECTOR GENERAL" Then TxtSignatureName.Value = "Hervé BLEJEAN" ElseIf ComboBoxSignature.Value = "DEPUTY DIRECTOR GENERAL" Then TxtSignatureName.Value = "Giovanni MANIONE" ElseIf ComboBoxSignature.Value = "DIRECTOR MPCC" Then TxtSignatureName.Value = "Hervé BLEJEAN" ElseIf ComboBoxSignature.Value = "DIRECTOR MPCC" Then TxtSignatureName.Value = "Hervé BLEJEAN" Else: TxtSignatureName.Value = "Herminio MAIO" End If If ComboBoxSignature.Value = "DIRECTOR GENERAL" Then TxtSignatureRank.Value = "Vice Admiral" ElseIf ComboBoxSignature.Value = "DIRECTOR MPCC" Then TxtSignatureRank.Value = "Vice Admiral" Else: TxtSignatureRank.Value = "Major General" End If End Sub
Private Sub ComboBoxDocType_Change() 'FrameLO.Visible = False 'FrameCoC.Visible = False 'FrameMA.Visible = False 'FrameEUMC.Visible = False FrameLetter.Visible = False FrameInternalOrder.Visible = False FrameNoteToDGDDG.Visible = False 'FrameMPCCLetter.Visible = False With Me 'Added this Line and subsequent Dots (".") dunno if "ME' Is appropriate Select Case .ComboBoxDocType.Value 'Case "Compilation of Comments": .FrameCoC.Visible = True 'Case "Lessons Observation": .FrameLO.Visible = True 'Case "EUMC Meeting Documents": .FrameEUMC.Visible = True 'Case "Military Advice": .FrameMA.Visible = True 'Case "EUMC Meeting Documents": .FrameEUMC.Visible = True Case "Letters": .FrameLetter.Visible = True Case "Internal Order": .FrameInternalOrder.Visible = True Case "Notes": .FrameNoteToDGDDG.Visible = True 'Case "MPCC Letter": .FrameMPCCLetter.Visible = True End Select End With End Sub
Sub InsertExistingBuildingBlock() Select Case ComboBoxDocType.ListIndex Case Is = 0 'First item in list AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "EUMSCoCCoverPage" AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "GeneralComments" Selection.InsertBreak Type:=wdSectionBreakNextPage If Selection.PageSetup.Orientation = wdOrientPortrait Then Selection.PageSetup.Orientation = wdOrientLandscape Else Selection.PageSetup.Orientation = wdOrientPortrait End If AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "SpecificComments" AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "CoCAbbreviations" With ActiveDocument .Bookmarks("EVTBookMark01Class").Range.Text = ComboBoxMarking.Value End With Case Is = 1 'Second item in list AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "Table" Case Is = 2 AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "EUMSCoverPage" AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "MAReferences" AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "INTRODUCTION" AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "CONSIDERATIONS" AutoTextToBM "EVTBookMark05", ActiveDocument.AttachedTemplate, "RECOMMENDATIONS" AutoTextToBM "EVTBookMarkEEASNrRepeatHdr", ActiveDocument.AttachedTemplate, "EEASNrRepeat" AutoTextToBM "EVTBookMarkEEASNrRepeatFtr", ActiveDocument.AttachedTemplate, "EEASNrRepeat" With ActiveDocument .Bookmarks("EVTBookMark01Class").Range.Text = ComboBoxMarking.Value End With Case Is = 3 AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "EUMSCoverPage" AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "AgendaAdoption" AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "AgendaPoint" AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "AgendaPointPossible" AutoTextToBM "EVTBookMark05", ActiveDocument.AttachedTemplate, "InformationAgenda" AutoTextToBM "EVTBookMark06", ActiveDocument.AttachedTemplate, "ProvAgendaNextmeeting" AutoTextToBM "EVTBookMark07", ActiveDocument.AttachedTemplate, "AOBat27" AutoTextToBM "EVTBookMark08", ActiveDocument.AttachedTemplate, "OpALTHEA" AutoTextToBM "EVTBookMark09", ActiveDocument.AttachedTemplate, "AOBat26" AutoTextToBM "EVTBookMark10", ActiveDocument.AttachedTemplate, "ProvAgendaNotes" AutoTextToBM "EVTBookMarkEEASNrRepeatHdr", ActiveDocument.AttachedTemplate, "EEASNrRepeat" AutoTextToBM "EVTBookMarkEEASNrRepeatFtr", ActiveDocument.AttachedTemplate, "EEASNrRepeat" With ActiveDocument .Bookmarks("EVTBookMark01Class").Range.Text = ComboBoxMarking.Value End With Case Is = 4 AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "EUMSCoverPage" AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "AgendaAdoption" AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "AgendaPoint" AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "AgendaPointPossible" AutoTextToBM "EVTBookMark05", ActiveDocument.AttachedTemplate, "InformationAgenda" AutoTextToBM "EVTBookMark06", ActiveDocument.AttachedTemplate, "AANextmeeting" AutoTextToBM "EVTBookMark07", ActiveDocument.AttachedTemplate, "AOBat27" AutoTextToBM "EVTBookMark08", ActiveDocument.AttachedTemplate, "OpALTHEA" AutoTextToBM "EVTBookMark09", ActiveDocument.AttachedTemplate, "AOBat26" AutoTextToBM "EVTBookMark10", ActiveDocument.AttachedTemplate, "AANotes" AutoTextToBM "EVTBookMarkEEASNrRepeatHdr", ActiveDocument.AttachedTemplate, "EEASNrRepeat" AutoTextToBM "EVTBookMarkEEASNrRepeatFtr", ActiveDocument.AttachedTemplate, "EEASNrRepeat" With ActiveDocument .Bookmarks("EVTBookMark01Class").Range.Text = ComboBoxMarking.Value End With Case Is = 5 Select Case ListBoxLetterOriginator.ListIndex Case Is = 1 AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "Header" AutoTextToBM "EVTbookMark02", ActiveDocument.AttachedTemplate, "LetterAuthor" AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "LetterDate" AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "LetterRecipient" AutoTextToBM "EVTBookMark05", ActiveDocument.AttachedTemplate, "LetterSubject" AutoTextToBM "EVTBookMark06", ActiveDocument.AttachedTemplate, "LetterReferences" AutoTextToBM "EVTBookMark07", ActiveDocument.AttachedTemplate, "LetterBody" AutoTextToBM "EVTBookMark08", ActiveDocument.AttachedTemplate, "LetterSignature" AutoTextToBM "EVTBookMark09", ActiveDocument.AttachedTemplate, "LetterAnnexes" Case Is = 2 AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "MPCCLetterHeader" AutoTextToBM "EVTbookMark02", ActiveDocument.AttachedTemplate, "LetterAuthor" AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "LetterDate" AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "LetterRecipient" AutoTextToBM "EVTBookMark05", ActiveDocument.AttachedTemplate, "LetterSubject" AutoTextToBM "EVTBookMark06", ActiveDocument.AttachedTemplate, "LetterReferences" AutoTextToBM "EVTBookMark07", ActiveDocument.AttachedTemplate, "LetterBody" AutoTextToBM "EVTBookMark08", ActiveDocument.AttachedTemplate, "LetterSignature" AutoTextToBM "EVTBookMark09", ActiveDocument.AttachedTemplate, "LetterAnnexes" End Select With ActiveDocument .Bookmarks("EVTBookMark02a").Range.Text = ComboBoxLetterAuthor.Value '.Bookmarks("EVTBookMarkMarkingHdr").Range.Text = ComboBoxLetterMarking.Value '.Bookmarks("EVTBookMarkMarkingFtr").Range.Text = ComboBoxLetterMarking.Value .Bookmarks("EVTBookMark03a").Range.Text = DTLetterDocDate.Value End With Dim LblLetterRecipientName As Range Set LblLetterRecipientName = ActiveDocument.Bookmarks("EVTBookMark04a").Range LblLetterRecipientName.Text = Me.TextBoxLetterRecipientName.Value Dim LblLetterRecipientAddress As Range Set LblLetterRecipientAddress = ActiveDocument.Bookmarks("EVTBookMark04b").Range LblLetterRecipientAddress.Text = Me.TextBoxLetterRecipientAddress.Value Dim LblLetterRecipientPlace As Range Set LblLetterRecipientPlace = ActiveDocument.Bookmarks("EVTBookMark04c").Range LblLetterRecipientPlace.Text = Me.TextBoxLetterRecipientPlace.Value Dim LblLetterRecipientCountry As Range Set LblLetterRecipientCountry = ActiveDocument.Bookmarks("EVTBookMark04d").Range LblLetterRecipientCountry.Text = Me.TextBoxLetterRecipientCountry.Value Dim LblLetterSubject As Range Set LblLetterSubject = ActiveDocument.Bookmarks("EVTBookMark05a").Range LblLetterSubject.Text = Me.TextBoxLetterSubject.Value Dim LblLetterSignatureName As Range Set LblLetterSignatureName = ActiveDocument.Bookmarks("EVTBookMark08a").Range LblLetterSignatureName.Text = Me.TextBoxLetterSignatureName.Value Dim LblLetterSignatureRank As Range Set LblLetterSignatureRank = ActiveDocument.Bookmarks("EVTBookMark08b").Range LblLetterSignatureRank.Text = Me.TextBoxLetterSignatureRank.Value Case Is = 6 Select Case ListBoxIOOriginator.ListIndex Case Is = 0 AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "IOHeader" AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "IOAdresseeSubject" AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "IOAim" AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "IOBackground" AutoTextToBM "EVTBookMark05", ActiveDocument.AttachedTemplate, "IOExecutionTask" AutoTextToBM "EVTBookMark06", ActiveDocument.AttachedTemplate, "IOValidity" AutoTextToBM "EVTBookMark07", ActiveDocument.AttachedTemplate, "IOSignature" With ActiveDocument '.Bookmarks("EVTBookMarkMarkingHdr").Range.Text = ComboBoxIOMarking.Value '.Bookmarks("EVTBookMarkMarkingFtr").Range.Text = ComboBoxIOMarking.Value .Bookmarks("EVTBookMark01a").Range.Text = ComboBoxSignature.Value .Bookmarks("EVTBookMark01b").Range.Text = DTDocDate.Value .Bookmarks("EVTBookMark01c").Range.Text = "EUMS INTERNAL ORDER " & ComboBoxIOYear.Value & " - " & ComboBoxIONumber.Value '.Bookmarks("EVTBookMark01d").Range.Text = "" End With Case Is = 1 AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "IOHeaderMPCC" AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "IOAdresseeSubject" AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "IOAim" AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "IOBackground" AutoTextToBM "EVTBookMark05", ActiveDocument.AttachedTemplate, "IOExecutionTask" AutoTextToBM "EVTBookMark06", ActiveDocument.AttachedTemplate, "IOValidity" AutoTextToBM "EVTBookMark07", ActiveDocument.AttachedTemplate, "IOSignature" With ActiveDocument '.Bookmarks("EVTBookMarkMarkingHdr").Range.Text = ComboBoxIOMarking.Value '.Bookmarks("EVTBookMarkMarkingFtr").Range.Text = ComboBoxIOMarking.Value .Bookmarks("EVTBookMark01a").Range.Text = ComboBoxSignature.Value .Bookmarks("EVTBookMark01b").Range.Text = "MILITARY PLANNING AND CONDUCT CAPABILITY" .Bookmarks("EVTBookMark01c").Range.Text = DTDocDate.Value .Bookmarks("EVTBookMark01d").Range.Text = "MPCC INTERNAL ORDER " & ComboBoxIOYear.Value & "-" & ComboBoxIONumberMPCC.Value '.Bookmarks("EVTBookMark01d").Range.Text = "" End With Case Is = 1 & 2 AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "IOHeaderJoint" AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "IOAdresseeSubject" AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "IOAim" AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "IOBackground" AutoTextToBM "EVTBookMark05", ActiveDocument.AttachedTemplate, "IOExecutionTask" AutoTextToBM "EVTBookMark06", ActiveDocument.AttachedTemplate, "IOValidity" AutoTextToBM "EVTBookMark07", ActiveDocument.AttachedTemplate, "IOSignature" With ActiveDocument '.Bookmarks("EVTBookMarkMarkingHdr").Range.Text = ComboBoxIOMarking.Value '.Bookmarks("EVTBookMarkMarkingFtr").Range.Text = ComboBoxIOMarking.Value .Bookmarks("EVTBookMark01a").Range.Text = ComboBoxSignature.Value .Bookmarks("EVTBookMark01c").Range.Text = DTDocDate.Value .Bookmarks("EVTBookMark01d").Range.Text = "EUMS INTERNAL ORDER " & ComboBoxIOYear.Value & "-" & ComboBoxIONumber.Value .Bookmarks("EVTBookMark01e").Range.Text = "MPCC INTERNAL ORDER " & ComboBoxIOYear.Value & "-" & ComboBoxIONumberMPCC.Value End With End Select Dim LblSubject As Range Set LblSubject = ActiveDocument.Bookmarks("EVTBookMark02a").Range LblSubject.Text = Me.TxtSubject.Value Dim LblSignatureName As Range Set LblSignatureName = ActiveDocument.Bookmarks("EVTBookMark07a").Range LblSignatureName.Text = Me.TxtSignatureName.Value Dim LblSignatureRank As Range Set LblSignatureRank = ActiveDocument.Bookmarks("EVTBookMark07b").Range LblSignatureRank.Text = Me.TxtSignatureRank.Value Case Is = 7 Select Case ListBoxNoteOriginator.ListIndex Case Is = 0 AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "NoteHeader" AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "NoteSubject" AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "NoteTable" AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "MAReferences" AutoTextToBM "EVTBookMark05", ActiveDocument.AttachedTemplate, "IOBackground" AutoTextToBM "EVTBookMark06", ActiveDocument.AttachedTemplate, "IOAim" AutoTextToBM "EVTBookMark07", ActiveDocument.AttachedTemplate, "NoteChallenges" AutoTextToBM "EVTBookMark08", ActiveDocument.AttachedTemplate, "NoteConsiderations" AutoTextToBM "EVTBookMark09", ActiveDocument.AttachedTemplate, "NoteOptions" AutoTextToBM "EVTBookMark10", ActiveDocument.AttachedTemplate, "NoteRecommendations" AutoTextToBM "EVTBooKMark11", ActiveDocument.AttachedTemplate, "NoteFinalDecision" Case Else AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "NoteHeaderMPCC" AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "NoteSubject" AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "NoteTable" AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "MAReferences" AutoTextToBM "EVTBookMark05", ActiveDocument.AttachedTemplate, "IOBackground" AutoTextToBM "EVTBookMark06", ActiveDocument.AttachedTemplate, "IOAim" AutoTextToBM "EVTBookMark07", ActiveDocument.AttachedTemplate, "NoteChallenges" AutoTextToBM "EVTBookMark08", ActiveDocument.AttachedTemplate, "NoteConsiderations" AutoTextToBM "EVTBookMark09", ActiveDocument.AttachedTemplate, "NoteOptions" AutoTextToBM "EVTBookMark10", ActiveDocument.AttachedTemplate, "NoteRecommendations" AutoTextToBM "EVTBooKMark11", ActiveDocument.AttachedTemplate, "NoteFinalDecision" End Select With ActiveDocument .Bookmarks("EVTBookMark01a").Range.Text = DTNoteDate.Value .Bookmarks("EVTBookMark01b").Range.Text = ComboBoxAttnOf.Value .Bookmarks("EVTBookMark01c").Range.Text = ComboBoxAim.Value .Bookmarks("EVTBookMark03b").Range.Text = ComboBoxRecommendation.Value .Bookmarks("EVTBookMark03c").Range.Text = DTDLNote.Value End With Dim LblNoteSubject As Range Set LblNoteSubject = ActiveDocument.Bookmarks("EVTBookMark02a").Range LblNoteSubject.Text = Me.TextBoxNoteSubject.Value Dim LblIssue As Range Set LblIssue = ActiveDocument.Bookmarks("EVTBookMark03a").Range LblIssue.Text = Me.TextBoxIssue.Value Dim LblFrom As Range Set LblFrom = ActiveDocument.Bookmarks("EVTBookMark03d").Range LblFrom.Text = Me.TextBoxFrom.Value Dim LblAgreedBy As Range Set LblAgreedBy = ActiveDocument.Bookmarks("EVTBookMark03e").Range LblAgreedBy.Text = Me.TextBoxAgreedBy.Value Case Is = 8 AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "EUMSCoverPage" AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "DGEUMSReportAll" AutoTextToBM "EVTBookMarkEEASNrRepeatHdr", ActiveDocument.AttachedTemplate, "EEASNrRepeat" AutoTextToBM "EVTBookMarkEEASNrRepeatFtr", ActiveDocument.AttachedTemplate, "EEASNrRepeat" With ActiveDocument .Bookmarks("EVTBookMark01Class").Range.Text = ComboBoxMarking.Value End With Case Else 'Nothing selected End Select End Sub
Cheers,Public Sub AutoTextToBM(strbmName As String, oTemplate As Template, strAutotext As String) 'Graham Mayor - http://www.gmayor.com - Last updated - 17 Dec 2017 'strBMName is the name of the bookmark to fill 'oTemplate is the template with the autotext - probably ActiveDocument.AttachedTemplate 'strAutotext is the name of the autotext entry Dim orng As Range On Error GoTo lbl_Exit With ActiveDocument Set orng = .Bookmarks(strbmName).Range Set orng = oTemplate.AutoTextEntries(strAutotext).Insert _ (Where:=orng, RichText:=True) .Bookmarks.Add Name:=strbmName, Range:=orng End With lbl_Exit: Exit Sub End Sub
Paskie_be




Reply With Quote