PDA

View Full Version : Port to word doc



Codeblue
06-23-2012, 10:48 AM
Hello
I want to export data from a ss onto a word doc. This code sort of works...

Dim AppWord As Object
Dim Wstmp As Worksheet

With Application
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
End With

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

'Sheets("Sheet1").Range("A1:A10,J1:J10").Copy
Range("A1:A50,F1:F50").Copy
Set Wstmp = Worksheets.Add
Wstmp.Range("a1").PasteSpecial xlPasteAll
Wstmp.UsedRange.Copy

AppWord.Documents.Add
'AppWord.Selection.PasteSpecial DataType:=wdPasteDefault
AppWord.Selection.Paste

Application.CutCopyMode = False
Wstmp.Delete

Set Wstmp = Nothing
Set AppWord = Nothing

With Application
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
End With
' new --------
'On Error GoTo ErrorHandler
Selection.WholeStory

If Document1.ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If

If ActiveWindow.ActivePane.View.Type <> wdPrintView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If

With Selection.PageSetup.TextColumns
.SetCount NumColumns:=1
.EvenlySpaced = False
.LineBetween = False
End With
but I am getting these blue dotted lines around my text on the word doc sort of a like a table. How can I get rid of these? Please see attached.

snb
06-23-2012, 01:08 PM
If you paste a range from Excel into Word it is converted into a table.

What is the use of copying a non contiguous range into a new worksheet ?

Codeblue
06-23-2012, 04:57 PM
Do you mean non contigious as in the columns I'm wanting to port over are not next to each other?

snb
06-24-2012, 03:30 AM
yes

Codeblue
06-24-2012, 06:45 AM
I'm required to send out a weekly report at work about our equipment sets and the work that was done to them. All the data that is enterend in our maintenance management system includes date, the tech doing the work, equipment status, and on and on. But in the report the only items that are needed are the tool name and the work performed. They are not side by side in our ma man sys.

I wonder if porting to a pdf may be better.

Kenneth Hobs
06-24-2012, 09:28 AM
Why do the blue dotted lines bother you? They are not printed.

Codeblue
06-24-2012, 10:39 AM
It just looks a little cheesey. It's not that serious but I want it to look a little more professional since it has my name on it. Management and everyone is seeing this.
It's not getting printed out.

Codeblue
06-25-2012, 12:46 PM
Is there any way to keep it from being a table when porting to word or changing the color from blue to white to make it non visible?

Tinbendr
06-25-2012, 01:05 PM
To turn table gridlines off.
ActiveDocument.ActiveWindow.View.TableGridlines = False
Interestingly, the 2007 macro recorder shows this code.
WordBasic.ShowTableGridlines

Codeblue
06-25-2012, 03:30 PM
Beautiful, just what I've been needing. I used the 1st example.
thanks!!!