'Option Explicit
Public Sub ToCreateMonthlySignSheet()
Application.ScreenUpdating = False
Dim WB As Workbook: Set WB = Workbooks.Add
Dim OpnWB As Workbook
Dim MdlFile As String, FileContent As String, TXT As String, TXT1 As String, TXT2 As String, Extn As String
Dim ZipFileName As Variant, FolderName As Variant, CustomUIFolder As Variant, imageFolder As Variant, relsFolder As Variant
Dim fso As Object
Dim wShApp As Object
Dim TextFile As Integer
TextFile = FreeFile
Dim file As Object
Dim YY As Long, MM As Long, B As Long, R As Long
Dim FullName As String, DefltPath As String, Filename As String
Filename = "Monthly Signin Sheet.xlsm"
DefltPath = Environ("USERPROFILE") & "\Desktop\"
FullName = DefltPath & Filename
ZipFileName = Replace(FullName, ".xlsm", ".zip")
FolderName = Replace(FullName, ".xlsm", "")
With WB
Dim ws As Worksheet: Set ws = .Worksheets(1)
'Close File if Open
On Error Resume Next
Set OpnWB = GetObject(, "Excel.Application")
Set OpnWB = GetObject(FullName)
If Not OpnWB Is Nothing Then
OpnWB.Close False
End If
If Len(Dir(FullName)) <> 0 Then Kill FullName
On Error GoTo 0
YY = 2020 '<<<<<<<
MM = 11 '<<<<<<<<<<<<
Dim Rng As Range
'Hide Fisrt Two Rows
Rows("1:2").EntireRow.Hidden = True
With ws
'Freeze First Row
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With
ActiveWindow.FreezePanes = True
.Name = "Monthly Sign Sheet"
.Activate
ActiveWindow.DisplayGridlines = False
With .Cells(1, 1)
.Value = YY
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.RowHeight = 25
End With
With .Cells(1, 2)
.Value = MM
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
With .Cells(3, 1).Resize(1, 5)
.Value = Array("Day/Date", "Time In", "Parent Signature", "Time Out", "Parent Signature")
With .Interior
.Pattern = xlSolid
.Color = RGB(47, 117, 181)
End With ' .Interior
With .Font
.Color = RGB(255, 255, 255)
.Name = "Times New Roman"
.Size = 13
.Bold = True
End With ' .Font
.ColumnWidth = VBA.Array(12, 17, 20, 17, 20) '<<<<<<<<<<<<<<<<< Column Width
.RowHeight = 30
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
End With ' .Cells(3, 1).Resize(1, 5)
With .Cells(4, 1).Resize(25, 1)
.FormulaArray = "=TEXT(DATE($A$1,$B$1,(ROW()-ROW($A$4)+1))+(((CEILING((ROW()-ROW($A$4)+1)+IF(WEEKDAY(DATE($A$1,$B$1,1))=1,WEEKDAY(DATE($A$1,$B$1,1))+1-2,WEEKDAY(DATE($A$1,$B$1,1))-2),5)/5)-1)*2)+IF(WEEKDAY(DATE($A$1,$B$1,1))=1,1,0),""dddd"" & CHAR(10) & "" mm/dd/yyyy"")"
.WrapText = True
.RowHeight = 30
.VerticalAlignment = xlCenter
With .Font
.Color = RGB(0, 0, 0)
.Name = "Times New Roman"
.Size = 12
.Bold = True
End With ' .Font
End With ' .Cells(4, 1).Resize(30, 1)
With .Cells(3, 1).Resize(26, 5)
For B = 7 To 12
With .Borders(B)
.LineStyle = xlContinuous
.Color = RGB(0, 0, 0)
.Weight = xlThin
End With
Next
End With ' .Cells(3, 1).Resize(31, 1)
For R = 4 To 28 '<<<<<<<<<<<<<<<<<
With .Cells(R, 1).Resize(1, 5)
.FormatConditions.Add Type:=xlExpression, Formula1:="=AND(MONTH(TRIM(MID(" & .Cells(1, 1).Address & ",FIND(CHAR(10)," & .Cells(1, 1).Address & ",1)+2,10)))=$B$1,MOD(ROWS($A$4:" & Cells(R, 1).Address(False, False) & "),2)=0)"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(203, 223, 241)
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = False
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=MONTH(TRIM(MID(" & .Cells(1, 1).Address & ",FIND(CHAR(10)," & .Cells(1, 1).Address & ",1)+2,10)))<>$B$1"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
.FormatConditions(1).Borders(xlLeft).LineStyle = xlNone
.FormatConditions(1).Borders(xlRight).LineStyle = xlNone
.FormatConditions(1).Borders(xlBottom).LineStyle = xlNone
.FormatConditions(1).StopIfTrue = False
End With
Next
With .Spinners.Add(.Cells(1, 1).Left, .Cells(1, 1).Top, 18, .Cells(1, 1).Height)
.Value = 2020
.Min = 2015
.Max = 2040
.SmallChange = 1
.LinkedCell = "$A$1"
.Display3DShading = False
End With
With .Spinners.Add(.Cells(1, 2).Left, .Cells(1, 1).Top, 18, .Cells(1, 1).Height)
.Value = 11
.Min = 1
.Max = 12
.SmallChange = 1
.LinkedCell = "$B$1"
.Display3DShading = False
End With
'''''''''''''''''
Application.PrintCommunication = False
With .PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
.PageSetup.PrintArea = "$A$3:$E$26"
Application.PrintCommunication = False
With .PageSetup
.RightFooter = "&""-,Bold Italic""&K7030A0jonwondon"
.LeftMargin = 30
.RightMargin = 30
.TopMargin = 60
.BottomMargin = 30
.HeaderMargin = 40
.FooterMargin = 25
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
Application.PrintCommunication = True
End With ' WS
'Create Module For Ribbons Controls
MdlFile = DefltPath & "RibbonsCnotrols.bas"
AddControlsModule MdlFile
'Import Module File
.VBProject.VBComponents.Import MdlFile
Kill MdlFile
'''''''''''''''''
On Error Resume Next
.SaveAs Filename:=FullName, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
.Close
On Error GoTo 0
End With ' WB
' Now start to Add Custon Ribbon Controls
'Convert Excel File to Zip File
If Dir(ZipFileName) <> "" Then Kill ZipFileName ' Delete Existing Zip File
Name FullName As ZipFileName
' Move Files into New Created Folder
Set fso = CreateObject("scripting.filesystemobject")
On Error Resume Next
fso.deletefolder FolderName
'1- Create Folder
MkDir FolderName
On Error GoTo 0
Application.Wait (Now + TimeValue("0:00:01"))
Set wShApp = CreateObject("Shell.Application")
'2-Transfere File
Do Until wShApp.Namespace(ZipFileName).Items.Count = 0
wShApp.Namespace(FolderName).MoveHere wShApp.Namespace(ZipFileName).Items
Application.Wait (Now + TimeValue("0:00:01"))
Loop
' Create Custom Folder For Custom XML File
CustomUIFolder = FolderName & "\customUI\"
MkDir CustomUIFolder
'Place "customUI14XML" into CustomUI Folder
customUI14xml CustomUIFolder & "customUI14.XML"
' Update _rels\.rels XML File
Open FolderName & "\_rels\.rels" For Input As TextFile: FileContent = Input(LOF(TextFile), TextFile): Close TextFile
TXT1 = "</Relationships>"
TXT2 = "<Relationship Id=""cuID14"" Type=""http://schemas.microsoft.com/office/2007/relationships/ui/extensibility"" Target=""customUI/customUI14.xml""/>"
FileContent = Replace(FileContent, TXT1, TXT2 & TXT1)
Open FolderName & "\_rels\.rels" For Output As TextFile: Print #TextFile, FileContent: Close TextFile
'Place "customUI14XML" into CustomUI Folder
imageFolder = CustomUIFolder & "images\"
MkDir imageFolder
'Load PDF Image
PDFImage imageFolder & "PDF.png"
'Create _rels Folder For Images
relsFolder = CustomUIFolder & "_rels\"
MkDir relsFolder
Set imageFolder = fso.GetFolder(imageFolder)
TXT = ""
Extn = ""
TXT = "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>" & vbNewLine
TXT = TXT & "<Relationships xmlns=""http://schemas.openxmlformats.org/package/2006/relationships"">" & vbNewLine
'Linked Images into custom rels Folder
For Each file In imageFolder.Files
TXT = TXT & "<Relationship Id=""" & Replace(file.Name, ".", "_") & """ Type=""http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"" Target=""" & Replace(Split(file.Path, "customUI\")(1), "\", "/") & """/>" & vbNewLine
If InStr(1, Extn, Split(file.Name, ".")(1)) = 0 Then Extn = Extn & "<Default Extension=""" & Split(file.Name, ".")(1) & """ ContentType=""image/." & Split(file.Name, ".")(1) & """/>"
Next
TXT = TXT & "</Relationships>"
' Write Linked Image XML File Into relsFolder
Open relsFolder & "customUI14.xml.rels" For Output As TextFile: Print #TextFile, TXT: Close TextFile
'Update [Content_Types].xml
Open FolderName & "\[Content_Types].xml" For Input As TextFile: FileContent = Input(LOF(TextFile), TextFile): Close TextFile
TXT1 = "<Types xmlns=""http://schemas.openxmlformats.org/package/2006/content-types"">"
TXT2 = Extn
FileContent = Replace(FileContent, TXT1, TXT1 & TXT2)
Open FolderName & "\[Content_Types].xml" For Output As TextFile: Print #TextFile, FileContent: Close TextFile
' Now All Custom File and Folder Complete, So will Zip them
Application.Wait (Now + TimeValue("0:00:01"))
On Error Resume Next
Do Until wShApp.Namespace(FolderName).Items.Count = 0
wShApp.Namespace(ZipFileName).MoveHere wShApp.Namespace(FolderName).Items ' should be MoveHere Not CopyHere
Application.Wait (Now + TimeValue("0:00:01"))
Loop
On Error GoTo 0
' Back Convert Zip File to Excel Work Book
Name ZipFileName As FullName
' Clead Temp Folder
Set fso = CreateObject("scripting.filesystemobject")
On Error Resume Next
fso.deletefolder FolderName
'Desktop Refresh
Dim objTMP As Object
Set objTMP = CreateObject("Shell.Application").Namespace(0)
With objTMP
.Self.InvokeVerb "R&efresh"
End With
Set objTMP = Nothing
''''''''''''''
Set MyFile = Workbooks.Open(FullName)
MyFile.Activate
Application.WindowState = xlMaximized
ActiveWindow.WindowState = xlMaximized
Application.ScreenUpdating = True
End Sub
Public Function AddControlsModule(FilePath As String) As String
Dim TXT As String
TXT = TXT & "Attribute VB_Name = ""RibbonsCnotrols""" & vbNewLine
TXT = TXT & "Public SignRbnUI As IRibbonUI" & vbNewLine
TXT = TXT & "Public TXTBOX1 As String" & vbNewLine
TXT = TXT & "Public TXTBOX2 As String" & vbNewLine
TXT = TXT & "Public WB As Workbook" & vbNewLine
TXT = TXT & "Public ws As Worksheet" & vbNewLine
TXT = TXT & "'Callback for customUI.onLoad" & vbNewLine
TXT = TXT & "Sub SignRbn(ribbon As IRibbonUI)" & vbNewLine
TXT = TXT & "Set SignRbnUI = ribbon" & vbNewLine
TXT = TXT & "TXTBOX1 = Cells(1, 1)" & vbNewLine
TXT = TXT & "TXTBOX2 = Cells(1, 2)" & vbNewLine
TXT = TXT & "End Sub" & vbNewLine
TXT = TXT & "'Callback for Combobox1 getItemCount" & vbNewLine
TXT = TXT & "Sub Cmbbox_getItemCount(control As IRibbonControl, ByRef returnedVal)" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " If control.ID = ""Combobox1"" Then" & vbNewLine
TXT = TXT & " returnedVal = 11" & vbNewLine
TXT = TXT & " ElseIf control.ID = ""Combobox1"" Then" & vbNewLine
TXT = TXT & " returnedVal = 12" & vbNewLine
TXT = TXT & " End If" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & "End Sub" & vbNewLine
TXT = TXT & "'Callback for Combobox1 getItemLabel" & vbNewLine
TXT = TXT & "Sub Cmbbox_getItemLabel(control As IRibbonControl, index As Integer, ByRef returnedVal)" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " If control.ID = ""Combobox1"" Then" & vbNewLine
TXT = TXT & " returnedVal = index + 2019" & vbNewLine
TXT = TXT & " ElseIf control.ID = ""Combobox2"" Then" & vbNewLine
TXT = TXT & " returnedVal = index + 1" & vbNewLine
TXT = TXT & " End If" & vbNewLine
TXT = TXT & "End Sub" & vbNewLine
TXT = TXT & "'Callback for Combobox1 getText" & vbNewLine
TXT = TXT & "Sub Cmbbox_getText(control As IRibbonControl, ByRef returnedVal)" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " If control.ID = ""Combobox1"" Then" & vbNewLine
TXT = TXT & " returnedVal = TXTBOX1" & vbNewLine
TXT = TXT & " ElseIf control.ID = ""Combobox2"" Then" & vbNewLine
TXT = TXT & " returnedVal = TXTBOX2" & vbNewLine
TXT = TXT & " End If" & vbNewLine
TXT = TXT & "End Sub" & vbNewLine
TXT = TXT & "'Callback for Combobox1 onChange" & vbNewLine
TXT = TXT & "Sub Cmbbox_onChange(control As IRibbonControl, text As String)" & vbNewLine
TXT = TXT & " If control.ID = ""Combobox1"" Then" & vbNewLine
TXT = TXT & " TXTBOX1 = text" & vbNewLine
TXT = TXT & " Cells(1, 1) = TXTBOX1" & vbNewLine
TXT = TXT & " ElseIf control.ID = ""Combobox2"" Then" & vbNewLine
TXT = TXT & " TXTBOX2 = text" & vbNewLine
TXT = TXT & " Cells(1, 2) = TXTBOX2" & vbNewLine
TXT = TXT & " End If" & vbNewLine
TXT = TXT & "SignRbnUI.Invalidate" & vbNewLine
TXT = TXT & "End Sub" & vbNewLine
TXT = TXT & "'Callback for Button1 onAction" & vbNewLine
TXT = TXT & "Sub Bttn_onAction(control As IRibbonControl)" & vbNewLine
TXT = TXT & " Set WB = ThisWorkbook: Set ws = WB.Worksheets(1)" & vbNewLine
TXT = TXT & " If control.ID = ""Button1"" Then" & vbNewLine
TXT = TXT & " TXTBOX1 = TXTBOX1 + 1" & vbNewLine
TXT = TXT & " Cells(1, 1) = TXTBOX1" & vbNewLine
TXT = TXT & " ElseIf control.ID = ""Button2"" Then" & vbNewLine
TXT = TXT & " TXTBOX1 = TXTBOX1 - 1" & vbNewLine
TXT = TXT & " Cells(1, 1) = TXTBOX1" & vbNewLine
TXT = TXT & " ElseIf control.ID = ""Button3"" Then" & vbNewLine
TXT = TXT & " TXTBOX2 = TXTBOX2 + 1" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " TXTBOX2 = ((TXTBOX2 - 1) Mod 12) + 1" & vbNewLine
TXT = TXT & " Cells(1, 2) = TXTBOX2" & vbNewLine
TXT = TXT & " ElseIf control.ID = ""Button4"" Then" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " TXTBOX2 = TXTBOX2 - 1" & vbNewLine
TXT = TXT & " If TXTBOX2 < 1 Then TXTBOX2 = 12" & vbNewLine
TXT = TXT & " TXTBOX2 = (((TXTBOX2 - 1) Mod 12) + 1)" & vbNewLine
TXT = TXT & " Cells(1, 2) = TXTBOX2" & vbNewLine
TXT = TXT & " ElseIf control.ID = ""Button5"" Then" & vbNewLine
TXT = TXT & " Sxport_To_Word" & vbNewLine
TXT = TXT & " ElseIf control.ID = ""Button6"" Then" & vbNewLine
TXT = TXT & " ToPDF" & vbNewLine
TXT = TXT & " ElseIf control.ID = ""Button7"" Then" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " ws.PrintOut Copies:=1, Collate:=True, _" & vbNewLine
TXT = TXT & " IgnorePrintAreas:=False" & vbNewLine
TXT = TXT & " End If" & vbNewLine
TXT = TXT & "SignRbnUI.Invalidate" & vbNewLine
TXT = TXT & "End Sub" & vbNewLine
TXT = TXT & "Public Sub Sxport_To_Word()" & vbNewLine
TXT = TXT & "Dim WB As Workbook" & vbNewLine
TXT = TXT & "Dim ws As Worksheet" & vbNewLine
TXT = TXT & "Dim wrdApp As Object" & vbNewLine
TXT = TXT & "Dim WrdDoc As Object" & vbNewLine
TXT = TXT & "Dim OpnWrd As Object" & vbNewLine
TXT = TXT & "Dim myRange As Object" & vbNewLine
TXT = TXT & "Dim Tbl As Object" & vbNewLine
TXT = TXT & "Dim R As Long" & vbNewLine
TXT = TXT & "Set WB = ThisWorkbook" & vbNewLine
TXT = TXT & "Set ws = WB.Worksheets(1) '""Sheet1"" or any Name ""Sheet_Name""" & vbNewLine
TXT = TXT & "Dim WrdPath As String" & vbNewLine
TXT = TXT & "Path = WB.Path" & vbNewLine
TXT = TXT & "WrdPath = Path & ""\"" & ""Monthly Signin Sheet.docx""" & vbNewLine
TXT = TXT & " On Error Resume Next" & vbNewLine
TXT = TXT & " Set OpnWrd = GetObject(, ""Word.Application"")" & vbNewLine
TXT = TXT & " Set OpnWrd = GetObject(WrdPath)" & vbNewLine
TXT = TXT & " If Not OpnWrd Is Nothing Then" & vbNewLine
TXT = TXT & " OpnWrd.Close False" & vbNewLine
TXT = TXT & " OpnWrd.Quit" & vbNewLine
TXT = TXT & " End If" & vbNewLine
TXT = TXT & " If Len(Dir(WrdPath)) <> 0 Then Kill WrdPath" & vbNewLine
TXT = TXT & " On Error GoTo 0" & vbNewLine
TXT = TXT & "Set wrdApp = CreateObject(""Word.Application"")" & vbNewLine
TXT = TXT & "Set WrdDoc = wrdApp.Documents.Add" & vbNewLine
TXT = TXT & "wrdApp.Visible = True" & vbNewLine
TXT = TXT & "WrdDoc.SaveAs WrdPath" & vbNewLine
TXT = TXT & "'do what" & vbNewLine
TXT = TXT & "'add table" & vbNewLine
TXT = TXT & "Set myRange = WrdDoc.Range(0, 0)" & vbNewLine
TXT = TXT & "'cop from excel" & vbNewLine
TXT = TXT & "CntRw = 0" & vbNewLine
TXT = TXT & "CntRw = [=AGGREGATE(14,6,(ROW($A$4:$A$28)-ROW($A$4)+1)/--(MONTH(TRIM(MID($A$4:$A$28,FIND(CHAR(10),$A$4:$A$28,1)+2,10)))=$B$1),1)]" & vbNewLine
TXT = TXT & "ws.Cells(3, 1).Resize(CntRw + 1, 5).Copy" & vbNewLine
TXT = TXT & "With wrdApp" & vbNewLine
TXT = TXT & " With .Selection" & vbNewLine
TXT = TXT & " .Paste" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " Set Tbl = .Tables(1)" & vbNewLine
TXT = TXT & " With Tbl" & vbNewLine
TXT = TXT & " .Rows.Alignment = 1 'wdAlignRowCenter" & vbNewLine
TXT = TXT & " .Rows.HeightRule = 1' wdRowHeightAtLeast" & vbNewLine
TXT = TXT & " .Rows.Height = 0" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " .Range.ParagraphFormat.LineSpacing = 13" & vbNewLine
TXT = TXT & " .Range.ParagraphFormat.SpaceBefore = 0" & vbNewLine
TXT = TXT & " .Range.ParagraphFormat.SpaceAfter = 0" & vbNewLine
TXT = TXT & " .Cell(1, 1).Range.ParagraphFormat.SpaceBefore = 6" & vbNewLine
TXT = TXT & " .Cell(1, 1).Range.ParagraphFormat.SpaceAfter = 6" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " .Range.ParagraphFormat.Alignment = 1' wdAlignParagraphCenter" & vbNewLine
TXT = TXT & " .Range.Cells.VerticalAlignment = 1' wdCellAlignVerticalCenter" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " .Columns(1).Cells.VerticalAlignment = wdCellAlignVerticalCenter" & vbNewLine
TXT = TXT & " '.Columns(1).Cells.Range.ParagraphFormat.Alignment = wdAlignParagraphLeft '<<<<<< Not working>>>>> So select One of below" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " ''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''" & vbNewLine
TXT = TXT & " 'For Each C In .Columns(1).Cells" & vbNewLine
TXT = TXT & " 'C.Range.ParagraphFormat.Alignment = wdAlignParagraphLeft'<<<<<< working Well>>>>>" & vbNewLine
TXT = TXT & " ' Next" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " 'or" & vbNewLine
TXT = TXT & " For R = 2 To .Columns(1).Cells.Count" & vbNewLine
TXT = TXT & " .Cell(R, 1).Range.ParagraphFormat.Alignment = 0'wdAlignParagraphLeft" & vbNewLine
TXT = TXT & " Next" & vbNewLine
TXT = TXT & " ''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''" & vbNewLine
TXT = TXT & " End With ' Tbl" & vbNewLine
TXT = TXT & " With .PageSetup" & vbNewLine
TXT = TXT & " .TopMargin = 36" & vbNewLine
TXT = TXT & " .BottomMargin = 36" & vbNewLine
TXT = TXT & " .LeftMargin = 36" & vbNewLine
TXT = TXT & " .RightMargin = 36" & vbNewLine
TXT = TXT & " .Gutter = 0" & vbNewLine
TXT = TXT & " .HeaderDistance = 36" & vbNewLine
TXT = TXT & " .FooterDistance = 36" & vbNewLine
TXT = TXT & " End With '.PageSetup" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " End With '.Selection" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " .Activate" & vbNewLine
TXT = TXT & "End With ' wrdApp" & vbNewLine
TXT = TXT & "'WrdDoc.Close True" & vbNewLine
TXT = TXT & "'wrdApp.Quit" & vbNewLine
TXT = TXT & "Application.CutCopyMode = False" & vbNewLine
TXT = TXT & "Set WrdDoc = Nothing" & vbNewLine
TXT = TXT & "Set wrdApp = Nothing" & vbNewLine
TXT = TXT & "End Sub" & vbNewLine
TXT = TXT & "Public Sub ToPDF()" & vbNewLine
TXT = TXT & "Dim PDFFileFullName As String" & vbNewLine
TXT = TXT & " Set WB = ThisWorkbook: Set ws = WB.Worksheets(1)" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " Path = Environ$(""USERPROFILE"") & ""\Desktop\""" & vbNewLine
TXT = TXT & " PDFFileFullName = Path & Split(WB.Name, ""."")(0) & "".PDF""" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & " ChDir Path: ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFFileFullName, Quality:=xlQualityStandard, _" & vbNewLine
TXT = TXT & " IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True" & vbNewLine
TXT = TXT & " " & vbNewLine
TXT = TXT & "End Sub" & vbNewLine
AddControlsModule = TXT
Open FilePath For Binary As #1: Put #1, 1, AddControlsModule: Close #1
End Function
Public Function customUI14xml(FilePath As String) As String
Dim TXT As String
Dim TextFile As Integer '
TextFile = FreeFile '
TXT = TXT & "<!--RibbonX Visual Designer (64-bit) 2.50 for Microsoft Excel CustomUI14 . XML Code produced on 2020/10/24-->" & vbNewLine
TXT = TXT & "<customUI " & vbNewLine
TXT = TXT & " xmlns=""http://schemas.microsoft.com/office/2009/07/customui""" & vbNewLine
TXT = TXT & " onLoad=""SignRbn"">" & vbNewLine
TXT = TXT & " <ribbon >" & vbNewLine
TXT = TXT & " <tabs >" & vbNewLine
TXT = TXT & " <tab " & vbNewLine
TXT = TXT & " id=""Tab1""" & vbNewLine
TXT = TXT & " insertBeforeMso=""TabHome""" & vbNewLine
TXT = TXT & " label=""Parent Signature"">" & vbNewLine
TXT = TXT & " <group id=""Group1"" >" & vbNewLine
TXT = TXT & " <box " & vbNewLine
TXT = TXT & " boxStyle=""vertical""" & vbNewLine
TXT = TXT & " id=""Box3"">" & vbNewLine
TXT = TXT & " <box " & vbNewLine
TXT = TXT & " boxStyle=""horizontal""" & vbNewLine
TXT = TXT & " id=""Box1"">" & vbNewLine
TXT = TXT & " <comboBox " & vbNewLine
TXT = TXT & " id=""Combobox1""" & vbNewLine
TXT = TXT & " getItemCount=""Cmbbox_getItemCount""" & vbNewLine
TXT = TXT & " getItemLabel=""Cmbbox_getItemLabel""" & vbNewLine
TXT = TXT & " getText=""Cmbbox_getText""" & vbNewLine
TXT = TXT & " onChange=""Cmbbox_onChange""/>" & vbNewLine
TXT = TXT & " <button " & vbNewLine
TXT = TXT & " id=""Button1""" & vbNewLine
TXT = TXT & " imageMso=""CatalogMergeGoToPreviousRecord""" & vbNewLine
TXT = TXT & " onAction=""Bttn_onAction""/>" & vbNewLine
TXT = TXT & " <button " & vbNewLine
TXT = TXT & " id=""Button2""" & vbNewLine
TXT = TXT & " imageMso=""CatalogMergeGoToNextRecord""" & vbNewLine
TXT = TXT & " onAction=""Bttn_onAction""/>" & vbNewLine
TXT = TXT & " </box >" & vbNewLine
TXT = TXT & " <box " & vbNewLine
TXT = TXT & " boxStyle=""horizontal""" & vbNewLine
TXT = TXT & " id=""Box2"">" & vbNewLine
TXT = TXT & " <comboBox " & vbNewLine
TXT = TXT & " id=""Combobox2""" & vbNewLine
TXT = TXT & " getItemCount=""Cmbbox_getItemCount""" & vbNewLine
TXT = TXT & " getItemLabel=""Cmbbox_getItemLabel""" & vbNewLine
TXT = TXT & " getText=""Cmbbox_getText""" & vbNewLine
TXT = TXT & " onChange=""Cmbbox_onChange""/>" & vbNewLine
TXT = TXT & " <button " & vbNewLine
TXT = TXT & " id=""Button3""" & vbNewLine
TXT = TXT & " imageMso=""CatalogMergeGoToPreviousRecord""" & vbNewLine
TXT = TXT & " onAction=""Bttn_onAction""/>" & vbNewLine
TXT = TXT & " <button " & vbNewLine
TXT = TXT & " id=""Button4""" & vbNewLine
TXT = TXT & " imageMso=""CatalogMergeGoToNextRecord""" & vbNewLine
TXT = TXT & " onAction=""Bttn_onAction""/>" & vbNewLine
TXT = TXT & " </box >" & vbNewLine
TXT = TXT & " </box >" & vbNewLine
TXT = TXT & " <separator id=""Separator1"" />" & vbNewLine
TXT = TXT & " <button " & vbNewLine
TXT = TXT & " id=""Button5""" & vbNewLine
TXT = TXT & " imageMso=""ExportWord""" & vbNewLine
TXT = TXT & " label=""Word""" & vbNewLine
TXT = TXT & " size=""large""" & vbNewLine
TXT = TXT & " onAction=""Bttn_onAction""/>" & vbNewLine
TXT = TXT & " <button " & vbNewLine
TXT = TXT & " id=""Button6""" & vbNewLine
TXT = TXT & " image=""PDF_png""" & vbNewLine
TXT = TXT & " label=""PDF""" & vbNewLine
TXT = TXT & " size=""large""" & vbNewLine
TXT = TXT & " onAction=""Bttn_onAction""/>" & vbNewLine
TXT = TXT & " <button " & vbNewLine
TXT = TXT & " id=""Button7""" & vbNewLine
TXT = TXT & " imageMso=""FilePrint""" & vbNewLine
TXT = TXT & " label=""Print""" & vbNewLine
TXT = TXT & " size=""large""" & vbNewLine
TXT = TXT & " onAction=""Bttn_onAction""/>" & vbNewLine
TXT = TXT & " </group >" & vbNewLine
TXT = TXT & " </tab >" & vbNewLine
TXT = TXT & " </tabs >" & vbNewLine
TXT = TXT & " </ribbon >" & vbNewLine
TXT = TXT & "</customUI >" & vbNewLine
customUI14xml = TXT
Open FilePath For Output As TextFile: Print #TextFile, customUI14xml: Close TextFile
End Function
Function PDFImage(FilePath As String) As String
Dim TXT As String
Dim TextFile As Integer '
TextFile = FreeFile
PDFImage = ""
PDFImage = PDFIm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NOOsn/oF+/1OQ+fRLtkr59N0m/fpuuzUnmXEk2va3IFEnfvt47vXuvPqdHj391isVO/h/wGSgTaCG2HgAAAABJRU5ErkJggg=="
Open FilePath For Binary As #1: Put #1, 1, DecodeBase64(PDFImage): Close #1
End Function
Function DecodeBase64(ByVal strData As String) As Byte()
' On Error Resume Next
Dim objXML As Object 'MSXML2.DOMDocument
Dim objNode As Object 'MSXML2.IXMLDOMElement
'get dom document
Set objXML = CreateObject("MSXML2.DOMDocument")
'create node with type of base 64 and decode
Set objNode = objXML.createElement("b64")
objNode.DataType = "bin.base64"
objNode.Text = strData
DecodeBase64 = objNode.nodeTypedValue
'clean up
Set objNode = Nothing
Set objXML = Nothing
End Function