Zavrieť

Porady

Makro: cez Word pustit excel prikaz End(xlDown)

Ahojte,

Potreboval by som dorobit makro ale nemozem zistit pocet riadkov v exceli kedze cez word tento prikaz nebere .... V exceli ten prikaz funguje: "Riadkov = Selection.Find(What:="s_outer_id").End(xlDown).Row "

Netusite preco?

makro:

Sub Makro1()

Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = msoTrue
objExcelApp.Workbooks.Open ActiveDocument.Path & "\xx.xls"
adresa = ActiveDocument.Path

objExcelApp.Rows("1:1").Select
Stlpec = objExcelApp.Selection.Find(What:="s_outer_id").Col umn
Riadkov = objExcelApp.Selection.Find(What:="s_outer_id").End (xlDown).Row

For Riadok = 2 To Riadkov
Start = Riadok
Nazov = objExcelApp.Cells(Riadok, Stlpec).Value

Select Case objExcelApp.Cells(Riadok, Stlpec).Value
Case Is = objExcelApp.Cells(Riadok + 4, Stlpec).Value
Riadok = Riadok + 4
Case Is = objExcelApp.Cells(Riadok + 3, Stlpec).Value
Riadok = Riadok + 3
Case Is = objExcelApp.Cells(Riadok + 2, Stlpec).Value
Riadok = Riadok + 2
Case Is = objExcelApp.Cells(Riadok + 1, Stlpec).Value
Riadok = Riadok + 1
End Select

With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = Start - 1
.LastRecord = Riadok - 1
End With
.Execute Pause:=False
End With

ActiveDocument.SaveAs FileName:=adresa & "\" & Nazov & ".doc", FileFormat:=wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveWindow.Close

Next Riadok

End Sub
Naposledy upravil Palo235 : 22.09.10 at 12:22
Téma je uzavretá.
Usporiadať podľa času

PaloPa je offline (nepripojený) PaloPa

PaloPa
Pri volaní príslušných XL akcií z Wordu treba odkaz na XL konštantu nahradiť jej hodnotou:

pre xlDown = -4121

Palo

Makro: cez Word pustit excel prikaz End(xlDown)

Porady, ktoré by vás mohli zaujímať

Prihláste sa a sledujte len tie Porady, ktoré Vás zaujímajú.