Professional Documents
Culture Documents
Dim wb As Workbook
Dim ws As Worksheet, ws2 As Worksheet
Dim applWord As Object
Dim docWord As Object
Sub idiuword()
Range("a5:a500").FormulaR1C1 =
"=IF(TRIM(RC[1])<>"""",COUNTA(R5C2:RC[1])&""."","""")"
'Range("A2").Select
'Dim wb As Workbook
'Dim ws As Worksheet, ws2 As Worksheet
Dim lastrow As Integer
Dim rowidx As Integer
Set wb = ActiveWorkbook
'Copy to a new sheet
'ActiveSheet.Copy After:=Sheets(Sheets.Count)
Set ws = Sheets(Sheets.Count)
With wb
With ws
'.Activate: .Select 'really only need one or the other
lastrow = Range("k32000").End(xlUp).Row 'Find the last row in col k
'Loop each row from the bottom up
For rowidx = lastrow To 2 Step -1
Range("k" & rowidx).Select 'only needed for debug
'If this Col k <> the one above it
If Range("k" & rowidx) <> Range("k" & rowidx - 1) Then
'Insert Row
Range("k" & rowidx).EntireRow.Insert (xlDown)
'Copy Firm to Header
Range("k" & rowidx).Offset(0, -2).Value = Range("k" & rowidx).Offset(1, 0).Value
Range("k" & rowidx).Offset(0, -2).Font.Bold = True
Range("k" & rowidx).Offset(0, -2).HorizontalAlignment = xlCenter
Range(Cells(rowidx, 1), Cells(rowidx, 10)).MergeCells = True
Else
'skip it
End If
Next rowidx
End With
End With
Dim lastrow1 As Long
Sub asd()
Dim tbl1 As Table
Dim tbl2 As Table
'set the Application object variable to create a new instance of Word:
Set applWord = CreateObject("Word.Application")
'make the Word window visible:
applWord.Visible = True
'maximize Word window:
'replaced the Word's built-in constant wdWindowStateMaximize with its numerical value 1.
applWord.WindowState = 1
'opens an existing word document from a defined folder:
Set docWord = applWord.Documents.Add(Environ("USERPROFILE") & "\My
Documents\01 kontrole\analiza_kontrola.dot")
'(Application.ActiveWorkbook.Path & "\" & "\analiza_kontrola.dot")
'Set ws2 = ThisWorkbook.Sheets("akt")
'Set ws1 = ThisWorkbook.Sheets("analiza")
Dim rngexcel As Range
Set rngexcel = ActiveWorkbook.Sheets("rekapitulacija1").Range("B5:K8")
docWord.Bookmarks("tabela2").Range.Select
rngexcel.Copy
applWord.Selection.Paste 'Link:=False, DataType:=1, Placement:=0,
DisplayAsIcon:=False
Set tbl1 = docWord.Tables(1)
With tbl1
.Rows.HeightRule = wdRowHeightAuto
.Range.Font.Size = 12
.Range.Font.Name = "Times New Roman"
.Rows.Alignment = wdAlignRowCenter
.Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
.Range.LanguageID = wdCroatian
End With
Dim rngexcel1 As Range
Set rngexcel1 = ActiveWorkbook.Sheets("rekapitulacija1").Range("B11:L20")
docWord.Bookmarks("tabela3").Range.Select
rngexcel1.Copy
applWord.Selection.Paste 'Link:=False, DataType:=1, Placement:=0,
DisplayAsIcon:=False