how to input from excel?

09/10/2007 - 05:39 von crazyfisher | Report spam
Dear all,

I want to input some contact information from excel to generate some
letters. how can I do that ? I know how to input from text file, however, it
doesn't work for excel.
this is my code:

Option Explicit
Dim D As Word.Document
Dim R As Word.Range
Dim x, inpTitle, inpFirstName, inpClient, inpSurName, inpAddress, inpSuburb,
inpTime, R1
Sub printletter()

Selection.HomeKey unit:=wdStory

'pay attention to the format and space out the commands
'vbcrlf--visual basic carriage return line feed
Open "E:\patient.xls" For Input As #1
' show the sequence of all types of data

Input #1, inpTitle, inpFirstName, inpSurName, inpAddress, inpSuburb,

Set D = Documents.Add("E:\")
Set R = D.Bookmarks("address").Range

R.InsertAfter inpTitle & " " & inpFirstName & " " & inpSurName & vbCrLf
R.InsertAfter inpAddress & vbCrLf
R.InsertAfter inpSuburb

Selection.TypeText Format(Date, "dd/mm/yy")

'Selection.TypeText inpTitle & " " & inputSurName

Set R1 = D.Bookmarks("name").Range
R1.InsertAfter inpTitle & " " & inpSurName

Selection.TypeText inpTime

'insert into the signature
Selection.InlineShapes.AddPicture FileName:="E:\sign.jpg",
LinkToFile:=False, SaveWithDocument:=True

'create more docs with the data.
x = x + 1
D.SaveAs ("E:\letter" & x & ".doc")
D.Close savechanges:=wdDoNotSaveChanges

Loop Until EOF(1)
Close #1
End Sub

Lesen sie die antworten

#1 Helmut Weber
09/10/2007 - 13:26 | Warnen spam
Hi Crazyfisher,


"input" is not suitable for files,
the binary or bytewise structure of which is unknown to you.

by the way, you posted this to a german speaking group.


Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & ""

Ähnliche fragen