Hi all
I am writing a VBA code, this is th first step of a lrage project
WHat I am trying to do is to put all the content of a word file (.doc) into a cell in access using this code:
Private Sub Command0_Click()
Dim app As Word.Application
Dim objDoc As Word.Document
Dim sVal As String
Set app = New Word.Application
Set objDoc = app.Documents.Open("C:\Documents and Settings\Administrator\Desktop\Magic Folder\test.doc")
sVal = objDoc.Content
sqls = "INSERT INTO Table1(TextContent) VALUES ('" & sVal & "');"
DoCmd.RunSQL sqls
objDoc.Close
Set objDoc = Nothing
app.Quit
Set app = Nothing
Debug.Print sVal
End Sub
SO when I try this with a small word file it works, if the file is too large i get an error
Run time error "3075" Syntax error missing operator in query expression, after this the error message displays part of the text in my word file
2 questions:
1-Is there a better way to do what I am trying ?
2-What is wrong with my code?
Regards
I am writing a VBA code, this is th first step of a lrage project
WHat I am trying to do is to put all the content of a word file (.doc) into a cell in access using this code:
Private Sub Command0_Click()
Dim app As Word.Application
Dim objDoc As Word.Document
Dim sVal As String
Set app = New Word.Application
Set objDoc = app.Documents.Open("C:\Documents and Settings\Administrator\Desktop\Magic Folder\test.doc")
sVal = objDoc.Content
sqls = "INSERT INTO Table1(TextContent) VALUES ('" & sVal & "');"
DoCmd.RunSQL sqls
objDoc.Close
Set objDoc = Nothing
app.Quit
Set app = Nothing
Debug.Print sVal
End Sub
SO when I try this with a small word file it works, if the file is too large i get an error
Run time error "3075" Syntax error missing operator in query expression, after this the error message displays part of the text in my word file
2 questions:
1-Is there a better way to do what I am trying ?
2-What is wrong with my code?
Regards