![]() |
|
#5
|
||||
|
||||
|
The process is essentially similar
Code:
Sub ColumnToPDF()
'Graham Mayor - https://www.gmayor.com - 21 September 2023
Dim oTable As Table
Dim oRng As Range
Dim oDoc As Document, oNew As Document
Dim intPos As Integer
Dim strDocName As String
Const strPath As String = "C:\path\" 'the path where the document is to be saved
If ActiveDocument.Tables.Count < 2 Then GoTo lbl_Exit
Set oDoc = ActiveDocument
Start:
strDocName = oDoc.Name
intPos = InStrRev(strDocName, ".")
If intPos = 0 Then
oDoc.Save
GoTo Start
End If
strDocName = Left(strDocName, intPos - 1)
strDocName = strPath & strDocName & ".pdf"
Set oTable = ActiveDocument.Tables(2)
oTable.Columns(1).Select
Selection.Copy
Set oNew = Documents.Add
Set oRng = oNew.Range
oRng.Paste
Debug.Print strDocName
oNew.ExportAsFixedFormat OutputFileName:=strDocName, ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, _
OptimizeFor:=wdExportOptimizeForPrint, _
Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, _
IncludeDocProps:=True, _
KeepIRM:=True, _
CreateBookmarks:=wdExportCreateHeadingBookmarks, _
DocStructureTags:=True, _
BitmapMissingFonts:=True, _
UseISO19005_1:=False
oNew.Close 0
lbl_Exit:
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
| Tags |
| word vba macro |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Narrow single-cell table with text wrapping doesn't allow table to break across pages | klyjen | Word Tables | 1 | 05-04-2023 04:55 PM |
Copy text from one table to another table in word document
|
rajsf123 | Word VBA | 1 | 10-21-2016 10:08 PM |
| Within a table format, a single cell can't automatically flow to the next page? | laurieli | Word | 3 | 12-09-2015 07:09 PM |
| How do I create a table in Word where I can single click a cell and it automatically highlights? | QA Inspector | Word | 2 | 05-14-2015 07:22 PM |
Can I create a single-cell table that moves with the text?
|
lcaretto | Word Tables | 7 | 11-01-2013 06:04 AM |