how can we load another documnet data into current document selection

  • Thread starter hemaneelagiri via OfficeKB.com
  • Start date
H

hemaneelagiri via OfficeKB.com

hi
i amd loading data from DB with VBA and my msword is 2003 with sp3

one of my column datatype is image[ in that i am storing data as bynarydata]

i am loading that data into my active document selection with below code

Private Sub LoadFile(ByVal objValue As Variant)
Dim sFileName As String
Dim mStream As Object
On Error Resume Next
sFileName = GetTempDir() & "temp123.doc"
Set mStream = CreateObject("ADODB.Stream")
With mStream
.Type = 1
.Open
.Write objValue
.SaveToFile sFileName, 2
End With

Set mStream = Nothing
Selection.InsertFile sFileName
On Error GoTo 0
End Sub

but the data is coming as junk and many pages(some hunders of pages)

when i am commented "on error" then below errors are coming

"arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another"

"Word cannot start the converter mswrd632"

can u please help me
 
H

hemaneelagiri via OfficeKB.com

when i am trying to open this in word 2007 it is working properly
hi
i amd loading data from DB with VBA and my msword is 2003 with sp3

one of my column datatype is image[ in that i am storing data as bynarydata]

i am loading that data into my active document selection with below code

Private Sub LoadFile(ByVal objValue As Variant)
Dim sFileName As String
Dim mStream As Object
On Error Resume Next
sFileName = GetTempDir() & "temp123.doc"
Set mStream = CreateObject("ADODB.Stream")
With mStream
.Type = 1
.Open
.Write objValue
.SaveToFile sFileName, 2
End With

Set mStream = Nothing
Selection.InsertFile sFileName
On Error GoTo 0
End Sub

but the data is coming as junk and many pages(some hunders of pages)

when i am commented "on error" then below errors are coming

"arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another"

"Word cannot start the converter mswrd632"

can u please help me
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top