Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking Spreadsheet Data to text file

Status
Not open for further replies.

mjcole

Mechanical
Jan 8, 2003
1,063
Hello,

Is it possible to have data in an Excel spread sheet that will be linked to a word document or word text file so that if changes are made to values in the spread sheet, they will also occur in the .doc or .txt file?

I have weights in a Bill Of Material spreadsheet that I want to link to a drawing file.

Michael
 
Replies continue below

Recommended for you

Draw a button on your sheet with the forms toolbar.
Copy and paste this code into a module
Right click on the button then assign the macro.
Press the button, hey presto


Option Base 1 'Set arrays to start at 1
Sub Getdata()

Dim ColumnList() As String

' Change this to your file path
MyDataFile = "C:\temp\tmp.txt"

Open MyDataFile For Output As #1

' Get each value from column A
For i = 1 To 65536
' If cell empty then exit loop
' Cells(Row, Column),
If ThisWorkbook.Sheets("Sheet1").Cells(i, 1) = "" Then Exit For
' Redimension the array for each row
ReDim Preserve ColumnList(i)
' Assign the value of the current
' row the current array element
ColumnList(i) = ThisWorkbook.Sheets("Sheet1").Cells(i, 1)

'Write data to file
Print #1, ColumnList(i)
Next i

'Close file
Close #1

End Sub

Hope this helps
 
All you need to do is "copy" the spread sheet and within word, click edit and paste special, then click "paste link" then ok. The spead sheet is now in word. What ever you do to the spread sheet will automatially be updated in the word document.

Nigel Waterhouse & Associates
Aeronautical Consulting Engineers

Transport Canada and F.A.A approval & certification of fixed and rotor wing aircraft alterations: Structures, Systems, Powerplants and electrical. FAA PMA, TC PDA.
n_a_waterhouse@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor