Advertisement
| 10.13.2008 at 03:05PM PDT, ID: 23811055 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 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: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: |
Sub ImportComments()
'Excel source file folder
Dim strExcelFolder As String
strExcelFolder = "c:\new format\"
'get the first excel file name
Dim strExcelFile As String
strExcelFile = Dir(strExcelFolder & "*.xls", vbNormal)
'if no files in the folder then exit routine
If strExcelFile = "" Then Exit Sub
'create Excel object
Dim objXL As Object
Set objXL = CreateObject("Excel.Application")
'define Excel object variables
Dim r As Integer 'row
Dim c As Object 'cell
Dim objWB As Object 'workbook
Dim objWS As Object 'worksheet
'while there are excel files to parse
While strExcelFile <> ""
'set the workbook and worksheet objects
Set objWB = objXL.Workbooks.Open(strExcelFolder & strExcelFile)
Set objWS = objWB.Sheets(1)
'set the intial row offset value
r = 1
'find the first row to start the import from
Set c = objWS.Cells.Find(What:="Review Comments", After:=objXL.ActiveWindow.ActiveCell, LookIn:=-4163, _
LookAt:=1, SearchOrder:=1, SearchDirection:=1, _
MatchCase:=True, SearchFormat:=False)
'if the starting cell is found
If Not c Is Nothing Then
'copy the defined cell range
objWS.Range("B6:C16").Copy
'paset the cell range into Word
Selection.PasteExcelTable False, False, True
'structure the pasted cell data table as desired
Selection.MoveLeft wdCharacter
With Selection.Tables(1)
'sinlge spaced lines
With .Range.ParagraphFormat
.SpaceBefore = 0
.SpaceAfter = 0
.LineSpacingRule = wdLineSpaceSingle
End With
'desired width for each column
.Columns(1).PreferredWidth = InchesToPoints(2.24)
.Columns(2).PreferredWidth = InchesToPoints(2.29)
End With
'create starting point and table for comment data
Selection.EndKey wdStory
Selection.TypeParagraph
'create table
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2, NumColumns:=2
With Selection.Tables(1)
.Borders.InsideLineStyle = wdLineStyleSingle
.Borders.OutsideLineStyle = wdLineStyleSingle
With .Cell(1, 1).Range
.Text = "Comments"
.Font.Bold = True
End With
With .Cell(1, 2).Range
.Text = "Recommended Action"
.Font.Bold = True
End With
.Cell(2, 1).Select
End With
'if the starting point has some shading applied
If c.Interior.Pattern <> -4142 Then
'cycle through each row until a COUNTIF formula is found to the cell one column to the left
While InStr(1, c.Offset(r, -1).Formula, "=countif", vbTextCompare) = 0
'if No column is checked off
If c.Offset(r, -2) <> "" Then
'enter the comment
Selection.TypeText c.Offset(r, 0).Value
Selection.MoveRight wdCell
'enter the recommended action
Selection.TypeText c.Offset(r, 1).Value
Selection.MoveRight wdCell
End If
'increment offset row
r = r + 1
Wend
End If
End If
'reset cell varaible
Set c = Nothing
'delete the last row which will be blank
Selection.Tables(1).Rows(Selection.Information(wdEndOfRangeRowNumber)).Delete
'close the workbook without savign changes
objWB.Close 2
'get the next ecxcel file to parse
strExcelFile = Dir
'if there is a file to parse start a new page
If strExcelFile <> "" Then Selection.InsertBreak
Wend
'close the excel application object
objXL.Quit
'resst all excel object variables
Set objXL = Nothing
Set objWS = Nothing
Set objWB = Nothing
End Sub
|
Advertisement