dj44
04-11-2016, 07:25 AM
Folks,
very good day to all on this monday.:)
I have got stuck on my table task.
I don't know if its possible at all - but i did get the idea from here.
http://stackoverflow.com/questions/13077740/create-text-files-from-every-row-in-an-excel-spreadsheet
I would like to save each row of my word table as a new document file.
it is set up like this
15891
Sub SaveTableRowAsNewFile()
' To save each row as a new document file
Dim strFolder As String ' For the folder where it will be saved
Dim strFile As String ' Table Column 1 - name of file?
Dim wdDoc As Document
Dim oTable As Table
Dim longindex as long
Set oTable = ActiveDocument.Tables(1) ' Table contains rows - each row to be saved as a file
oTable.Cell(oTable.Rows.Count, 2).Range.FormattedText = wdDoc.Range.FormattedText
'Keep original line breaks in content
'Extract the data?
' Filename Column 1 - start in Row 2
wdDoc.SaveAs2 Filename:=strPath & oTable.Cell(oTable.Rows.Count, longindex, 2) & ".docx", AddToRecentFiles:=False
wdDoc.Close
Next longindex
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
I have tried googling for any information to get it up and running but i dont seem to be able to find anything.
I am grateful if anyone can point me in the right direction
thank you very much to the pro coders for your valuable time
DJ
very good day to all on this monday.:)
I have got stuck on my table task.
I don't know if its possible at all - but i did get the idea from here.
http://stackoverflow.com/questions/13077740/create-text-files-from-every-row-in-an-excel-spreadsheet
I would like to save each row of my word table as a new document file.
it is set up like this
15891
Sub SaveTableRowAsNewFile()
' To save each row as a new document file
Dim strFolder As String ' For the folder where it will be saved
Dim strFile As String ' Table Column 1 - name of file?
Dim wdDoc As Document
Dim oTable As Table
Dim longindex as long
Set oTable = ActiveDocument.Tables(1) ' Table contains rows - each row to be saved as a file
oTable.Cell(oTable.Rows.Count, 2).Range.FormattedText = wdDoc.Range.FormattedText
'Keep original line breaks in content
'Extract the data?
' Filename Column 1 - start in Row 2
wdDoc.SaveAs2 Filename:=strPath & oTable.Cell(oTable.Rows.Count, longindex, 2) & ".docx", AddToRecentFiles:=False
wdDoc.Close
Next longindex
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
I have tried googling for any information to get it up and running but i dont seem to be able to find anything.
I am grateful if anyone can point me in the right direction
thank you very much to the pro coders for your valuable time
DJ