View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Henry[_4_] Henry[_4_] is offline
external usenet poster
 
Posts: 72
Default export to word without tables

Gus,

I don't know how this'll work for you, but it may be a way around the
problem.
Set up a Word.doc (mymargins.doc) in Word with the correct margins and save
it in the same directory as your XL project.
Instead of adding (APPWD.Documents.Add) a new document, open an instance of
your saved doc and paste into that.

APPWD.ChangeFileOpenDirectory ActiveWorkbook.Path
'Word looks here for file

APPWD.Documents.Open Filename:= "mymargins.doc", ConfirmConversions:=False,
ReadOnly:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="",
Format:=wdOpenFormatAuto

APPWD.Selection.Paste

You'll have to print or save the doc (with a unique name) and close it
before you can open a new instance for your next lot of cut and paste.

HTH
Henry

"GUS" wrote in message
...
I am using the following code in order to export part of a sheet to a new
word document and then correct the page margins
The problem is that i want to remove the tables from word especially where
is only text.
The tables are created from worksheet guide lines .


Sub exportword()
Worksheets("PRAKTIKO_ISOL").Select
''''''CREATE WORD PRAKTIKO ISOL

Application.CutCopyMode = xlCut
Application.DisplayAlerts = False
On Error Resume Next


Dim APPWD As Object

Dim i As Integer

Set APPWD = CreateObject("Word.Application")
APPWD.Visible = True



Sheets("PRAKTIKO_ISOL").Select
'Find the last row with data in the database

finalrow = Range("A9999").End(xlUp).Row
''For i = 2 To FinalRow
Sheets("PRAKTIKO_ISOL").Select
Range(Cells(1, 1), Cells(finalrow, 4)).Copy
' Tell Word to create a new document
APPWD.Documents.Add
' Tell Word to paste the contents of the clipboard into the new
document

APPWD.Selection.Paste


Application.CutCopyMode = xlCut

With APPWD.ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
''.TopMargin = CentimetersToPoints(2.54)
''.BottomMargin = CentimetersToPoints(2.54)
''.LeftMargin = CentimetersToPoints(2)
''.RightMargin = CentimetersToPoints(2)
''.Gutter = CentimetersToPoints(0)
''.HeaderDistance = CentimetersToPoints(1.25)
''.FooterDistance = CentimetersToPoints(1.25)
''.PageWidth = Application.InchesToPoints(21)
''.PageHeight = Application.InchesToPoints(29.7)
.LeftMargin = Application.InchesToPoints(1)
.RightMargin = Application.InchesToPoints(1)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(1.25)
.FooterMargin = Application.InchesToPoints(1.25)
End With

Application.DisplayAlerts = True

End Sub