Trying to create word macro to insert into SQL Server

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Have the following macro that inserts records from SQL table -

Selection.Range.InsertDatabase Format:=0, Style:=0, LinkToSource:=False, _
Connection:= _
"Provider=MSDASQL.1;Persist Security Info=True;Extended
Properties=""DSN=Spirit Group;UID=sa;APP=Microsoft Office
2003;WSID=YOUR-HKI1ASH75M;DATABASE=Spirit Group"";Initial Catalog=Spirit
Group" _
, SQLStatement:="SELECT * FROM ""HEATDb""" & "",
PasswordDocument:="", _
PasswordTemplate:="", WritePasswordDocument:="",
WritePasswordTemplate:= _
"", DataSource:= _
"C:\Documents and Settings\ian_clark.SOLUTEC\My Documents\My Data
Sources\Spirit Group HEATDb.odc" _
, From:=-1, To:=-1, IncludeFields:=True

How can I insert into this table i.e. need to do the following the SQL
syntax is – insert into
heatdb (dbname,tablename) values (‘abcd’,’abcd’)

Is it possible via a word macro?
 
I don't know many New Users that can write in VBA! I recommend that you post
this into microsoft.public.word.vba.beginners or
microsoft.public.word.vba.general newsgroups for a faster response (although
if you wait a while, one of the VBA gurus may pass by here later).

--
Terry Farrell - Word MVP
http://word.mvps.org/

: Have the following macro that inserts records from SQL table -
:
: Selection.Range.InsertDatabase Format:=0, Style:=0, LinkToSource:=False,
_
: Connection:= _
: "Provider=MSDASQL.1;Persist Security Info=True;Extended
: Properties=""DSN=Spirit Group;UID=sa;APP=Microsoft Office
: 2003;WSID=YOUR-HKI1ASH75M;DATABASE=Spirit Group"";Initial Catalog=Spirit
: Group" _
: , SQLStatement:="SELECT * FROM ""HEATDb""" & "",
: PasswordDocument:="", _
: PasswordTemplate:="", WritePasswordDocument:="",
: WritePasswordTemplate:= _
: "", DataSource:= _
: "C:\Documents and Settings\ian_clark.SOLUTEC\My Documents\My Data
: Sources\Spirit Group HEATDb.odc" _
: , From:=-1, To:=-1, IncludeFields:=True
:
: How can I insert into this table i.e. need to do the following the SQL
: syntax is – insert into
: heatdb (dbname,tablename) values (‘abcd’,’abcd’)
:
: Is it possible via a word macro?
:
:
: --
: Thanks for any assistance you can give.
:
: Cheers
: Ian
 
Back
Top