View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed[_9_] Ed[_9_] is offline
external usenet poster
 
Posts: 194
Default Why is my clipboard empty?

I wrote a macro to filter my worksheet and hide certain columns, then sort
and select the results and copy to the clipboard so I can paste into Word.
It worked fine - until I stuck in some more code to un-filter, un-sort, and
un-hide everything to reset the workbook. Then, when the code opens my Word
doc, the clipboard is empty. What am I doing wrong?

Ed

Here's the relevant sections. This works if I comment out between the ***.

' Put range on clipboard
ActiveCell.SpecialCells(xlLastCell).Select
Range(Selection, Cells(1)).Select
Selection.Copy

***

' Reset worksheet
' Unhide everything
Sheets("Sheet1").Activate

Sheets("Sheet1").AutoFilterMode = False

With Cells
.EntireColumn.Hidden = False
.EntireRow.Hidden = False
End With

' Resort to TIR No.
' Module 12
SortTIRNo

***

' Open template, which has Auto_Open macro
' to paste clipboard and make EFF tables
doc = "C:\Documents and
Settings\username\Desktop\Reports\TablesTemplate.d oc"
Set WD = CreateObject("Word.Application")
WD.Documents.Open doc
WD.Visible = True

End Sub