I am opening a HTML file in Word and using the SaveAS command to save it to a different name. Next I try to load the file to a ADODB.Stream and get an error stating that the file is locked. Here is part of the code:
Word.ActiveDocument.SaveAs wfileName
Set cn = CreateObject("ADODB.Connection"
cn.ConnectionString = "Provider=sqloledb;Data Source="
cn.ConnectionString = cn.ConnectionString & "PHILL\SQL2000" & ";Initial Catalog=" & "umantest" & ";User id=sa;password=;"
cn.CursorLocation = adUseClient
cn.Open
Set Cmd = CreateObject("ADODB.Command"
Set Cmd.ActiveConnection = cn
Set stm = New ADODB.Stream
rs.Open "select * from policy where PKPOL1 = " & policy, cn, adOpenKeyset, adLockOptimistic
stm.Type = adTypeBinary
stm.Open
stm.LoadFromFile (wfileName)
rs!DOM = stm.Read
rs.Update
rs.Close
stm.Close
Set Cmd = Nothing
Set rs = Nothing
Set stm = Nothing
Word.ActiveWindow.Close
Unload Me
The stm.LoadFromFile fails with a file locked error message.
If there some way to unlock the file so stm can read the file?
Word.ActiveDocument.SaveAs wfileName
Set cn = CreateObject("ADODB.Connection"
cn.ConnectionString = "Provider=sqloledb;Data Source="
cn.ConnectionString = cn.ConnectionString & "PHILL\SQL2000" & ";Initial Catalog=" & "umantest" & ";User id=sa;password=;"
cn.CursorLocation = adUseClient
cn.Open
Set Cmd = CreateObject("ADODB.Command"
Set Cmd.ActiveConnection = cn
Set stm = New ADODB.Stream
rs.Open "select * from policy where PKPOL1 = " & policy, cn, adOpenKeyset, adLockOptimistic
stm.Type = adTypeBinary
stm.Open
stm.LoadFromFile (wfileName)
rs!DOM = stm.Read
rs.Update
rs.Close
stm.Close
Set Cmd = Nothing
Set rs = Nothing
Set stm = Nothing
Word.ActiveWindow.Close
Unload Me
The stm.LoadFromFile fails with a file locked error message.
If there some way to unlock the file so stm can read the file?