Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-16-2021, 09:43 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Need help, get error message when place tbl.... Windows 10 Need help, get error message when place tbl.... Office 2019
Competent Performer
Need help, get error message when place tbl....
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Default Need help, get error message when place tbl....

Hello, Pros,
I'm desprately trying to fix a macro I've created to have every column in a table, from Column 1 (top to bottom), then next column (top to bottom), then next column (top to bottom), etc. place as ONE Column. I've started with 3 columns, to have 1.

Well I keep getting an error message when it wants to pasteAndFormat

What am I doing wrong? Cause when I do step by step (F8), it works.



We need to put the starting cursor in column 1, then use this macro:

HTML Code:
Sub T1fr_Merge_3Col_Vert_as_1_TST_BETTER()
'This macro is to have every Rows, from each column in a table from Left to Right, under each other, as 1 column

'T1fr_Fusionne_3Col_Vert_en_1_sous_TST_BETTER
'  TST_Selection_Col_2n3_Start_Col1_part1 Macro
'
Application.ScreenUpdating = False
'
' Select column l, then go to Column 2
    
    ActiveDocument.Tables(1).Columns(2).Select
    Selection.SelectColumn
    Selection.EndKey Unit:=wdRow, Extend:=True
    Selection.EndKey Unit:=wdColumn, Extend:=True

'Select column 2+3, Cut then paste below table 1
    Selection.Copy
    Selection.Cut
    Selection.EndKey Unit:=wdColumn, Extend:=True
    Selection.MoveDown Unit:=wdLine, Count:=2
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.PasteAndFormat (wdFormatOriginalFormatting)
    Selection.MoveUp Unit:=wdLine, Count:=2
    Selection.MoveRight Unit:=wdCell
    Selection.SelectColumn
    Selection.EndKey Unit:=wdColumn, Extend:=True
    
'Select column 3, Cut then paste below table 2
    Selection.Copy
    Selection.Cut
    Selection.EndKey Unit:=wdColumn
    Selection.MoveDown Unit:=wdLine, Count:=2
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.PasteAndFormat (wdFormatOriginalFormatting)
    
'  Remove extra paragraph marks to get all tables as 1
    Selection.MoveUp Unit:=wdLine, Count:=1
    Selection.HomeKey Unit:=wdColumn
    Selection.MoveUp Unit:=wdLine, Count:=2
    Selection.Delete Unit:=wdCharacter, Count:=2
    
    Selection.MoveUp Unit:=wdLine, Count:=1
    Selection.HomeKey Unit:=wdColumn
    Selection.MoveUp Unit:=wdLine, Count:=2
    Selection.Delete Unit:=wdCharacter, Count:=2
    
'Resize the whole table as 1 column, page wide
    Selection.SelectColumn
    Selection.Tables(1).AutoFitBehavior (wdAutoFitContent)
    Selection.Tables(1).AutoFitBehavior (wdAutoFitContent)
    Selection.Tables(1).AutoFitBehavior (wdAutoFitWindow)
    Selection.Tables(1).AutoFitBehavior (wdAutoFitWindow)
    Exit Sub

Application.ScreenUpdating = True
    
    On Error GoTo 0

End Sub
Any insights, please let me know, it's driving me crazy

Cendrinne
Reply With Quote
 

Tags
error message, pasteandformat table



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Error Message Run time Error 4605 baes10 Word VBA 1 08-30-2018 02:37 PM
Error Message PointCheck Word VBA 1 08-13-2018 02:42 PM
No known fix for this error message... Aymincendiary PowerPoint 1 09-03-2017 05:38 PM
Need help, get error message when place tbl.... Reserved error(-1517); there is no message for this error ktest Office 1 02-12-2016 08:08 PM
Need help, get error message when place tbl.... Automation error Unknown error" message once they open the Excel file hlina Excel 1 10-08-2013 09:14 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:43 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft