View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
TJA TJA is offline
external usenet poster
 
Posts: 5
Default Saving excel data to load into word

Please help....

I wrote this macro in excel exporting excel data so it can be loaded into
word document. It is not working... I can't get it to debub.

Thank you


Sub File_Export()
'
' File_Export Macro
' Export Style Worksheet to Word
'
' Keyboard Shortcut: Ctrl+Shift+F
'
'Export file for MS Word
'

Dim Filename As String
Dim NumRows As Long, NumCols As Integer
Dim r As Long, c As Integer
Dim Data
Dim ExpRng As Range

ThisWorkbook.Worksheets("person").Activate
Set ExpRng = Range("A5:N30")
NumCols = ExpRng.Columns.Count
NumRows = ExpRng.Rows.Count
Filename = "f:\foundations\excel_program\styles.txt"
Open Filename For Output As #1
For r = 1 To NumRows
For c = 1 To NumCols
Data = ExpRng.Cells(r, c).Value
If IsNumeric(Data) Then Data = Val(Data)
If IsEmpty(ExpRng.Cells(r, c)) Then Data = ""
If c < NumCols Then
Write #1, Data;
Else
Write #1, Data
End If
Next c
Next r
Close #1
ThisWorkbook.Worksheets("blank").Activate
End Sub