Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
GUS GUS is offline
external usenet poster
 
Posts: 45
Default export to word without tables

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I export XLS tables to MySQL? lobl Excel Discussion (Misc queries) 5 September 8th 09 04:39 AM
Export or Import into WORD l_croft1[_2_] New Users to Excel 4 May 13th 09 03:58 AM
export excel to word kath New Users to Excel 1 April 9th 09 10:22 PM
user level security-stop export of tables salmonella Excel Discussion (Misc queries) 1 December 20th 06 09:37 PM
How do I get data (tables) from IE to export to an EXCEL sreadshee WebgirlMD Excel Discussion (Misc queries) 2 January 19th 05 08:41 PM


All times are GMT +1. The time now is 03:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"