Вы находитесь на странице: 1из 11

Attribute VB_Name = "ReportGeneration"

'------------------------------------------------------------------------' Module
: ReportGeneration by Jaime Diaz (unless otherwise stated)
' Author
: Jaime Diaz (c) 2016
' Created : 08-25-2016
' Purpose : Collects all the framework necessary for results reporting
'------------------------------------------------------------------------'Ensure the following references have been added
'
- Visual Basic For Applications
'
- OLE Automation
'
- Microsoft Excel 15.0 Object Library
'
- Microsoft Office 15.0 Object Library
'
- Microsoft Forms 2.0 Object Library
'
- Microsoft Visual Basic for Applications Extensibility 5.3
'
- Microsoft Scripting Runtime
'
- Microsoft ActiveX Data Objects 6.1 Library
'
- Microsoft ActiveX Data Objects Recordset 6.0 Library
Option Explicit
Sub CreateReport()
'------------------------------------------------------------------------' Procedure : CreateReport
' Company :
' Author
: Jaime Diaz
' Created : 08-25-2016
' Purpose : Creation of results based on Dash Board Data
'------------------------------------------------------------------------Dim x As Integer
Dim lastRow As Long, currRow As Long
Dim sApp As String, sFileName As String, sPath As String, xlPath As String
Dim wdApp As Word.Application, wdDoc As Word.Document, wdSelection As Word.S
election, wdPara As Word.Paragraph
Dim xlWB As Workbook, xlSH As Object, xlChart As Chart
'Esure the workbook is saved before starting a macro, this will prevent a lo
ss of data
'and programming time as well as the dashboard sheets if they have not been
saved
ThisWorkbook.Sheets("Start Here").Range("I50").value = "Start Time: " & Form
at(Now(), "yyyy-MM-dd hh:mm:ss")
ThisWorkbook.Sheets("Start Here").Range("I51").value = "End Time: Not comple
ted"
ThisWorkbook.Save
'If MS Word is not open, open Word
sApp = "Word.Application"
If Not aaaMyLibrary.IsAppRunning(sApp) = True Then
' Open Word, and get instance
Set wdApp = CreateObject(sApp)
Else
Set wdApp = GetObject(, sApp)
End If
'Word Application does not need to be visible for this to run.
'wdApp.Visible = True
' Data begins on line 3
currRow = 3
If aaaMyLibrary.IsIn(ThisWorkbook.Sheets, "Dash Board") Then ProcessMeterRep
orts wdApp:=wdApp, currRow:=currRow
If aaaMyLibrary.IsIn(ThisWorkbook.Sheets, "Line Dash Board") Then ProcessLin
eReports wdApp:=wdApp, currRow:=currRow

On Error Resume Next


ThisWorkbook.Sheets("Start Here").Range("I51").value = "End Time: " & Format
(Now(), "yyyy-MM-dd hh:mm:ss")
wdApp.Quit
Set wdPara = Nothing
Set wdDoc = Nothing
Set wdApp = Nothing
Set xlWB = Nothing
Set wdSelection = Nothing
Set xlChart = Nothing
End Sub
Sub ProcessMeterReports(wdApp As Word.Application, ByVal currRow As Long)
'------------------------------------------------------------------------' Procedure : CreateReport
' Company :
' Author
: Jaime Diaz
' Created : 08-25-2016
' Purpose : Creation of results based on Dash Board Data
'------------------------------------------------------------------------Dim x As Integer
Dim lastRow As Long
Dim sApp As String, sFileName As String, sPath As String, xlPath As String
Dim wdDoc As Word.Document, wdSelection As Word.Selection, wdPara As Word.Pa
ragraph
Dim xlWB As Workbook, xlSH As Object, xlChart As Chart
'Status bar varibles
Dim Progress As Single
Dim Progress_Char As String, Space_Char As String, Start_Char As String, End
_Char As String
Dim CompletedSteps As Long, RemainingSteps As Long
' MaxWidth sets the width of the progress bar, on the status bar
Const MaxWidth = 40
Start_Char = "[ "
End_Char = " ] "
Progress_Char = "|" ' [|||| ]
Space_Char = " "
lastRow = ThisWorkbook.Sheets("Dash Board").UsedRange.SpecialCells(xlCellTyp
eLastCell).Row
For currRow = 3 To lastRow
'Process Status Bar updates for user information
If currRow > 3 Then Progress = (currRow - 3) * 100 / (lastRow - 3) Else
Progress = 0
CompletedSteps = Progress / 100 * MaxWidth
RemainingSteps = MaxWidth - CompletedSteps
DoEvents
Application.StatusBar = Start_Char & WorksheetFunction.Rept(Progress_Cha
r, Round(CompletedSteps, 0)) & WorksheetFunction.Rept(Space_Char, Round(Remainin
gSteps, 0)) & End_Char & " - Processing Meter Set Reports " & Progress & "% Comp
lete"
'If there is no Document named as the Set (Meter/Line) column A, create
one
sFileName = ThisWorkbook.Sheets("Dash Board").Range("A" & currRow).value
sPath = GetAddress(ThisWorkbook.Sheets("Dash Board").Range("A" & currRow
))
xlPath = Application.ThisWorkbook.Path
'Verify if file was processed
'Cross reference file name on log sheet and verify if processed, if it a
ppears on the Dash Board, it should be procesed

If Application.WorksheetFunction.IfError(Application.WorksheetFunction.V
Lookup(ThisWorkbook.Sheets("Dash Board").Range("A" & currRow).value, ThisWorkboo
k.Sheets("Dash Board").Range("A:B"), 2, False), 0) = 0 Then
GoTo SkipMeterLoop
End If
'Check if excel doc is open, if not open it
If Not aaaMyLibrary.IsIn(Workbooks, sFileName) Then
Set xlWB = Workbooks.Open(xlPath & "\" & sPath, False, True)
Else
Set xlWB = Workbooks(sFileName)
End If
'Search for report doc, if not create it
If Not aaaMyLibrary.IsIn(wdApp.Documents, Mid(sFileName, 1, InStr(sFileN
ame, ".") - 1) & ".docx") Then
'Open Template and popualte the header, the example document templat
e has all header and footer items needed and 2 fields, one for the Title and one
for the date
Set wdDoc = wdApp.Documents.Open(ThisWorkbook.Path & "\PGE Template.
dotx", False, True)
wdDoc.SelectContentControlsByTitle("Title")(1).Range.Text = Mid(sFil
eName, 1, InStr(sFileName, ".") - 1)
wdDoc.SelectContentControlsByTitle("Date")(1).Range.Text = Format(No
w, "MMMM dd, yyyy")
wdDoc.SaveAs2 fileName:=xlPath & "\Reports\" & Mid(sFileName, 1, InS
tr(sFileName, ".") - 1) & ".docx", FileFormat:=Word.wdFormatXMLDocument
Else
Set wdDoc = wdApp.Documents(Mid(sFileName, 1, InStr(sFileName, ".")
- 1) & ".docx")
End If
Set wdSelection = wdApp.Selection
wdSelection.TypeParagraph
'Add the title and skip two lines
wdSelection.Style = wdDoc.Styles("Title")
wdSelection.TypeText Mid(sFileName, 1, InStr(sFileName, ".") - 1) & " Re
sults"
wdSelection.TypeParagraph
wdSelection.TypeParagraph
'Begin by Stating the Overall results of the tested Set
wdSelection.Font.Name = "Arial"
wdSelection.Font.size = 10
wdSelection.TypeText "Overall analysis results are as follows:"
wdSelection.TypeParagraph
wdUseBullets wdApp, wdDoc, wdSelection, False
wdSelection.TypeText Text:="Net Result:" & vbTab & ThisWorkbook.Sheets("
Dash Board").Range("AB" & currRow).value
wdSelection.TypeParagraph
wdEndBullets wdSelection
wdSelection.TypeParagraph
'Add a TabStop at 3"
wdSelection.ParagraphFormat.TabStops.Add Position:=wdApp.InchesToPoints(
3.01), Alignment:=Word.wdAlignTabLeft, Leader:=Word.wdTabLeaderSpaces
wdSelection.TypeText "Results per Test Performed:"
wdSelection.TypeParagraph
wdUseBullets wdApp, wdDoc, wdSelection, False
addTestResultGroup wdSelection, "Instant Flow", "E", currRow
addTestResultGroup wdSelection, "Current Hour", "H", currRow
addTestResultGroup wdSelection, "Current Day", "K", currRow
addTestResultGroup wdSelection, "Current Month", "N", currRow
addTestResultGroup wdSelection, "Previous Hour", "Q", currRow
addTestResultGroup wdSelection, "Previous Day", "T", currRow

'addTestResultGroup wdSelection, "Previous Month", "W", currRow


addTestResultGroup wdSelection, "Planned Day", "Z", currRow
wdEndBullets wdSelection
'Remove the TabStop at 3"
wdSelection.ParagraphFormat.TabStops.ClearAll
wdDoc.DefaultTabStop = wdApp.InchesToPoints(0.5)
'Create a signature area
wdAddSignatureBlock wdApp, wdDoc, wdSelection
wdSelection.HomeKey Unit:=wdStory
wdSelection.EndKey Unit:=wdStory
'to copy a chart sheet object from excel
'set the chart sheet active
xlWB.Charts("Analysis Chart").Activate
'Export Instant Flow Graph as image, change graph
' to Current Day, and also export to image.
For x = 1 To 2
If x = 1 Then
wdSelection.TypeText "Instant Flow Chart:"
wdSelection.TypeParagraph
selectDesiredGraph xlWB, "Instant Flow"
Else
wdSelection.TypeText "Current Day Chart:"
wdSelection.TypeParagraph
selectDesiredGraph xlWB, "Current Day"
End If
Set xlChart = xlWB.Charts("Analysis Chart")
xlChart.ChartArea.Copy
'Continue by adding the charts images to the document
wdSelection.PasteSpecial Link:=False, DataType:=Word.wdPasteEnhanced
Metafile, Placement:=wdInLine, DisplayAsIcon:=False 'Works
wdSelection.TypeParagraph
wdSelection.InsertBreak Type:=Word.wdPageBreak
wdSelection.MoveDown
Next x
'Create an appendix for the raw data for the Set validated (Citect / Tel
vent)
'Create a PDF file for distribution
SaveDoc2PDF wdDoc:=wdDoc
'Close & Save the Document
wdDoc.Close SaveChanges:=True
'Close Excel Workbook
xlWB.Close SaveChanges:=False
SkipMeterLoop:
Next currRow
Application.StatusBar = vbNullString
End Sub
Sub ProcessLineReports(wdApp As Word.Application, ByVal currRow As Long)
'------------------------------------------------------------------------' Procedure : CreateReport
' Company :
' Author
: Jaime Diaz
' Created : 08-25-2016
' Purpose : Creation of results based on Dash Board Data
'------------------------------------------------------------------------Dim x As Integer
Dim lastRow As Long
Dim sApp As String, sFileName As String, sPath As String, xlPath As String

Dim wdDoc As Word.Document, wdSelection As Word.Selection, wdPara As Word.Pa


ragraph
Dim xlWB As Workbook, xlSH As Object, xlChart As Chart
'Status bar varibles
Dim Progress As Single
Dim Progress_Char As String, Space_Char As String, Start_Char As String, End
_Char As String
Dim CompletedSteps As Long, RemainingSteps As Long
' MaxWidth sets the width of the progress bar, on the status bar
Const MaxWidth = 40
Start_Char = "[ "
End_Char = " ] "
Progress_Char = "|" ' [|||| ]
Space_Char = " "
lastRow = ThisWorkbook.Sheets("Line Dash Board").UsedRange.SpecialCells(xlCe
llTypeLastCell).Row
For currRow = 3 To lastRow
'Process Status Bar updates for user information
If currRow > 3 Then Progress = (currRow - 3) * 100 / (lastRow - 3) Else
Progress = 0
CompletedSteps = Progress / 100 * MaxWidth
RemainingSteps = MaxWidth - CompletedSteps
DoEvents
Application.StatusBar = Start_Char & WorksheetFunction.Rept(Progress_Cha
r, Round(CompletedSteps, 0)) & WorksheetFunction.Rept(Space_Char, Round(Remainin
gSteps, 0)) & End_Char & " - Processing Line Set Reports " & Progress & "% Compl
ete"
'If there is no Document named as the Set (Meter/Line) column A, create
one
sFileName = ThisWorkbook.Sheets("Line Dash Board").Range("A" & currRow).
value
sPath = GetAddress(ThisWorkbook.Sheets("Line Dash Board").Range("A" & cu
rrRow))
xlPath = Application.ThisWorkbook.Path
'Verify if file was processed
'Cross reference file name on log sheet and verify if processed, if it a
ppears on the Dash Board, it should be procesed
If Application.WorksheetFunction.IfError(Application.WorksheetFunction.V
Lookup(ThisWorkbook.Sheets("Dash Board").Range("A" & currRow).value, ThisWorkboo
k.Sheets("Dash Board").Range("A:B"), 2, False), 0) = 0 Then
GoTo SkipLineLoop
End If
'Check if excel doc is open, if not open it
If Not aaaMyLibrary.IsIn(Workbooks, sFileName) Then
Set xlWB = Workbooks.Open(xlPath & "\" & sPath, False, True)
Else
Set xlWB = Workbooks(sFileName)
End If
'Search for report doc, if not create it
If Not aaaMyLibrary.IsIn(wdApp.Documents, Mid(sFileName, 1, InStr(sFileN
ame, ".") - 1) & ".docx") Then
'Open Template and popualte the header
Set wdDoc = wdApp.Documents.Open(ThisWorkbook.Path & "\PGE Template.
dotx", False, True)
wdDoc.SelectContentControlsByTitle("Title")(1).Range.Text = Mid(sFil
eName, 1, InStr(sFileName, ".") - 1)
wdDoc.SelectContentControlsByTitle("Date")(1).Range.Text = Format(No
w, "MMMM dd, yyyy")
wdDoc.SaveAs2 fileName:=xlPath & "\Reports\" & Mid(sFileName, 1, InS

tr(sFileName, ".") - 1) & ".docx", FileFormat:=Word.wdFormatXMLDocument


Else
Set wdDoc = wdApp.Documents(Mid(sFileName, 1, InStr(sFileName, ".")
- 1) & ".docx")
End If
Set wdSelection = wdApp.Selection
'The following block has been commented as I will be using a standard PG
&E Template
wdSelection.TypeParagraph
'Add the title and skip two lines
wdSelection.Style = wdDoc.Styles("Title")
wdSelection.TypeText Mid(sFileName, 1, InStr(sFileName, ".") - 1) & " Re
sults"
wdSelection.TypeParagraph
wdSelection.TypeParagraph
'Begin by Stating the Overall results of the tested Set
wdSelection.Font.Name = "Arial"
wdSelection.Font.size = 10
wdSelection.TypeText "Overall analysis results are as follows:"
wdSelection.TypeParagraph
wdUseBullets wdApp, wdDoc, wdSelection, False
wdSelection.TypeText Text:="Net Result:" & vbTab & ThisWorkbook.Sheets("
Line Dash Board").Range("M" & currRow).value
wdSelection.TypeParagraph
wdEndBullets wdSelection
wdSelection.TypeParagraph
'Add a TabStop at 3"
wdSelection.ParagraphFormat.TabStops.Add Position:=wdApp.InchesToPoints(
3.01), Alignment:=Word.wdAlignTabLeft, Leader:=Word.wdTabLeaderSpaces
wdSelection.TypeText "Results per Test Performed:"
wdSelection.TypeParagraph
wdUseBullets wdApp, wdDoc, wdSelection, False
addTestResultGroup wdSelection, "Inventory", "E", currRow, True
addTestResultGroup wdSelection, "Previous Inventory", "H", currRow, True
addTestResultGroup wdSelection, "Pack / Draft", "K", currRow, True
wdEndBullets wdSelection
'Remove the TabStop at 3"
wdSelection.ParagraphFormat.TabStops.ClearAll
wdDoc.DefaultTabStop = wdApp.InchesToPoints(0.5)
'Create a signature area
wdAddSignatureBlock wdApp, wdDoc, wdSelection
wdSelection.HomeKey Unit:=wdStory
wdSelection.EndKey Unit:=wdStory
'to copy a chart sheet object from excel
'set the chart sheet active
xlWB.Charts("Analysis Chart").Activate
'Export Instant Flow Graph as image, change graph
' to Current Day, and also export to image.
For x = 1 To 3
Select Case x
Case 1
wdSelection.TypeText "Inventory:"
wdSelection.TypeParagraph
selectDesiredGraph xlWB, "Inventory"
Case 2
wdSelection.TypeText "Previous Inventory:"
wdSelection.TypeParagraph
selectDesiredGraph xlWB, "Previous Inventory"
Case 3
wdSelection.TypeText "Pack / Draft:"

wdSelection.TypeParagraph
selectDesiredGraph xlWB, "Pack / Draft"
End Select
Set xlChart = xlWB.Charts("Analysis Chart")
xlChart.ChartArea.Copy
'Continue by adding the charts images to the document
wdSelection.PasteSpecial Link:=False, DataType:=Word.wdPasteEnhanced
Metafile, Placement:=wdInLine, DisplayAsIcon:=False 'Works
wdSelection.TypeParagraph
wdSelection.InsertBreak Type:=Word.wdPageBreak
wdSelection.MoveDown
Next x
'Create an appendix for the raw data for the Set validated (Citect / Tel
vent)
'Create a PDF file for distribution
SaveDoc2PDF wdDoc:=wdDoc
'Close & Save the Document
wdDoc.Close SaveChanges:=True
'Close Excel Workbook
xlWB.Close SaveChanges:=False
SkipLineLoop:
Next currRow
Application.StatusBar = vbNullString
End Sub
Sub SaveDoc2PDF(wdDoc As Word.Document)
'------------------------------------------------------------------------' Procedure : SaveDoc2PDF Created by Jaime Diaz
' Company :
' Author
: Jaime Diaz
' Created : 09-01-2016
' Purpose : Converts Word Document to PDF
'------------------------------------------------------------------------With wdDoc
.ExportAsFixedFormat OutputFileName:=.Path & "\" & Mid(.Name, 1, InStr(.
Name, ".") - 1) & ".pdf", _
ExportFormat:=Word.wdExportFormatPDF, OpenAfterExport:=False, Op
timizeFor:=Word.wdExportOptimizeForPrint, _
Item:=Word.wdExportDocumentContent, CreateBookmarks:=Word.wdExpo
rtCreateHeadingBookmarks
End With
End Sub
Sub selectDesiredGraph(xlWB As Workbook, sGraphName As String)
'------------------------------------------------------------------------' Procedure : selectDesiredGraph Created by Jaime Diaz
' Company :
' Author
: Jaime Diaz
' Created : 09-01-2016
' Purpose : Updates Graph on Analysis report to the desider one
'------------------------------------------------------------------------Dim x As Integer, y As Integer
For x = 1 To UBound(xlWB.Charts("Analysis Chart").DropDowns("cmbChartDD").Li
st)
If xlWB.Charts("Analysis Chart").DropDowns("cmbChartDD").List(x) = sGrap
hName Then Exit For
Next x

xlWB.Charts("Analysis Chart").DropDowns("cmbChartDD").Selected(x) = True


Application.Run xlWB.Name & "!ReconfigureChart"
End Sub
Sub wdAddSignatureBlock(wdApp As Word.Application, wdDoc As Word.Document, wdSel
ection As Word.Selection)
'------------------------------------------------------------------------' Procedure : wdAddSignatureBlock Created by Jaime Diaz
' Company :
' Author
: Jaime Diaz
' Created : 09-01-2016
' Purpose : Add the notes and signature block to the document
'------------------------------------------------------------------------Dim wdCurrParaFormat As Word.ParagraphFormat, wdCurrFontSize As Single
'Get the current Paragraph format
Set wdCurrParaFormat = wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Format
wdCurrFontSize = wdSelection.Font.size
wdSelection.TypeParagraph
wdSelection.TypeParagraph
wdSelection.Font.Bold = True
wdSelection.TypeText "Notes:"
wdSelection.TypeParagraph
wdSelection.TypeParagraph
wdSelection.TypeParagraph
wdSelection.TypeParagraph
wdSelection.TypeParagraph
wdSelection.TypeParagraph
wdSelection.TypeParagraph
wdSelection.TypeParagraph
wdSelection.TypeParagraph
wdSelection.Font.Bold = False
wdSelection.Font.Underline = wdUnderlineSingle
wdSelection.Font.size = 10
wdSelection.TypeText "PROCEDURE APPROVAL:"
wdSelection.TypeParagraph
wdSelection.Font.Underline = wdUnderlineNone
wdSelection.TypeParagraph
With wdSelection.ParagraphFormat
.TabStops.Add Position:=wdApp.InchesToPoints(2.5), Alignment:=Word.wdAli
gnTabLeft, Leader:=Word.wdTabLeaderSpaces
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
End With
wdSelection.Font.Bold = True
wdSelection.TypeText "Test Procedure Author:"
wdSelection.Font.Bold = False
wdSelection.TypeText vbTab & "______________________________________________
____"
wdSelection.TypeParagraph
wdSelection.ParagraphFormat.TabStops.ClearAll
wdDoc.DefaultTabStop = wdApp.InchesToPoints(0.5)
wdSelection.ParagraphFormat.TabStops.Add Position:=wdApp.InchesToPoints(3.5)
, Alignment:=Word.wdAlignTabLeft, Leader:=Word.wdTabLeaderSpaces
wdSelection.TypeText vbTab & "Signature / Date / LAN ID"
wdSelection.TypeParagraph
wdSelection.ParagraphFormat.TabStops.ClearAll

wdDoc.DefaultTabStop = wdApp.InchesToPoints(0.5)
wdSelection.ParagraphFormat.TabStops.Add Position:=wdApp.InchesToPoints(2.5)
, Alignment:=Word.wdAlignTabLeft, Leader:=Word.wdTabLeaderSpaces
wdSelection.TypeParagraph
wdSelection.Font.Bold = True
wdSelection.TypeText "Gas SCADA:"
wdSelection.Font.Bold = False
wdSelection.TypeText vbTab & "______________________________________________
____"
wdSelection.TypeParagraph
wdSelection.ParagraphFormat.TabStops.ClearAll
wdDoc.DefaultTabStop = wdApp.InchesToPoints(0.5)
wdSelection.ParagraphFormat.TabStops.Add Position:=wdApp.InchesToPoints(3.5)
, Alignment:=Word.wdAlignTabLeft, Leader:=Word.wdTabLeaderSpaces
wdSelection.TypeText vbTab & "Signature / Date / LAN ID"
wdSelection.InsertBreak Type:=Word.wdPageBreak
wdSelection.MoveLeft Unit:=wdCharacter, Count:=2
wdSelection.TypeBackspace
wdSelection.MoveDown
wdSelection.ParagraphFormat.TabStops.ClearAll
wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Format = wdCurrParaFormat
wdSelection.Font.size = wdCurrFontSize
wdDoc.DefaultTabStop = wdApp.InchesToPoints(0.5)
Set wdCurrParaFormat = Nothing
End Sub
Sub addTestResultGroup(wdSelection As Word.Selection, sTitle As String, sResultC
ol As String, currRow As Long, Optional ByVal isLine As Boolean = False)
'------------------------------------------------------------------------' Procedure : addTestResultGroup Created by Jaime Diaz
' Company :
' Author
: Jaime Diaz
' Created : 09-01-2016
' Purpose : Add a test result group of lines with corresponding formatting
'------------------------------------------------------------------------Dim xlSheet As Worksheet
If isLine Then Set xlSheet = ThisWorkbook.Sheets("Line Dash Board") Else Set
xlSheet = ThisWorkbook.Sheets("Dash Board")
With xlSheet
wdSelection.TypeText Text:=sTitle & ":" & vbTab & .Range(sResultCol & cu
rrRow).value
wdSelection.TypeParagraph
wdSelection.Range.ListFormat.ListIndent
wdSelection.TypeText Text:="Valid Samples:" & vbTab & .Range(Chr(Asc(sRe
sultCol) - 2) & currRow).value
wdSelection.TypeParagraph
wdSelection.TypeText Text:="Pass Ratio:" & vbTab & .Range(Chr(Asc(sResul
tCol) - 1) & currRow).value
wdSelection.TypeParagraph
wdSelection.Range.ListFormat.ListOutdent
End With
End Sub
Sub wdAddSamuelHeader(wdApp As Word.Application, wdDoc As Word.Document, wdSelec
tion As Word.Selection)
'------------------------------------------------------------------------' Procedure : wdAddSamuelHeader Created by Jaime Diaz
' Company :
' Author
: Jaime Diaz

' Created : 09-01-2016


' Purpose : Adds a standard Samuel Engineering Header on the fly
'
Not used, instead of creating a header a template was
'
used, and fields added for rapid modification
'------------------------------------------------------------------------wdApp.ActiveWindow.ActivePane.View.SeekView = Word.wdSeekCurrentPageHeader
wdSelection.InlineShapes.AddPicture fileName:="C:\Users\jdiaz\OneDrive - Sam
uel Engineering-\Personal Documents\16108\SamuelLogo.jpg", LinkToFile:=False, Sa
veWithDocument:=True
wdSelection.MoveRight Unit:=Word.wdCharacter, Count:=1
wdSelection.TypeParagraph
wdSelection.Font.size = 9
wdSelection.TypeText Text:="8450 East Crescent Parkway, Suite 200" & vbTab &
vbTab & "Phone: 303.714.4840"
wdSelection.TypeParagraph
wdSelection.TypeText Text:="Greenwood Village, CO 80111" & vbTab & vbTab & "
FAX: 303.714.4800"
wdApp.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
Sub wdUseBullets(wdApp As Word.Application, wdDoc As Word.Document, wdSelection
As Word.Selection, ByVal ContinuePrevList As Boolean)
'------------------------------------------------------------------------' Procedure : wdUseBullets Created by Jaime Diaz
' Company :
' Author
: Jaime Diaz
' Created : 09-01-2016
' Purpose : Changes all paragraph formating to use bullets
'------------------------------------------------------------------------With wdApp.ListGalleries(Word.wdBulletGallery).ListTemplates(1).ListLevels(1
)
.NumberFormat = ChrW(61623)
.TrailingCharacter = Word.wdTrailingTab
.NumberStyle = Word.wdListNumberStyleBullet
.NumberPosition = wdApp.InchesToPoints(0.25)
.Alignment = Word.wdListLevelAlignLeft
.TextPosition = wdApp.InchesToPoints(0.5)
.TabPosition = Word.wdUndefined
.ResetOnHigher = 0
.StartAt = 1
With .Font
.Bold = Word.wdUndefined
.Italic = Word.wdUndefined
.Strikethrough = Word.wdUndefined
.Subscript = Word.wdUndefined
.Superscript = Word.wdUndefined
.Shadow = Word.wdUndefined
.Outline = Word.wdUndefined
.Emboss = Word.wdUndefined
.Engrave = Word.wdUndefined
.Allcaps = Word.wdUndefined
.Hidden = Word.wdUndefined
.Underline = Word.wdUndefined
.Color = Word.wdUndefined
.size = Word.wdUndefined
.Animation = Word.wdUndefined
.DoubleStrikeThrough = Word.wdUndefined
.Name = "Symbol"
End With

.LinkedStyle = ""
End With
wdApp.ListGalleries(Word.wdBulletGallery).ListTemplates(1).Name = ""
wdSelection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
wdApp.ListGalleries(Word.wdBulletGallery).ListTemplates(1), ContinuePrev
iousList:= _
ContinuePrevList, ApplyTo:=Word.wdListApplyToWholeList, DefaultListBehav
ior:= _
Word.wdWord10ListBehavior
End Sub
Sub wdEndBullets(wdSelection As Word.Selection)
'------------------------------------------------------------------------' Procedure : wdEndBullets Created by Jaime Diaz
' Company :
' Author
: Jaime Diaz
' Created : 09-01-2016
' Purpose : Terminates the use bullets
'------------------------------------------------------------------------wdSelection.Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph
End Sub

Вам также может понравиться