View Single Post
 
Old 01-23-2012, 01:31 PM
Joe Patrick Joe Patrick is offline Windows 7 64bit Office 2007
Advanced Beginner
 
Join Date: May 2011
Posts: 33
Joe Patrick is on a distinguished road
Default Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248

Hi,

Can anyone tell me why this is not working? I get "runtime error 4248 - because no document is open" on the 'with activedocument" line although it is open and visible.

Thank you!

Code:
 
Dim objWord As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Documents.Open "\\Toolbox\bulletinboard\EIP_template.doc"
 
With ActiveDocument
.TextBox1.Value = ThisWorkbook.Sheets("SDF & ER").Range("A13").Value
.TextBox2.Value = ThisWorkbook.Sheets("SDF & ER").Range("J7").Value
.TextBox3.Value = ThisWorkbook.Sheets("SDF & ER").Range("A10").Value
.TextBox4.Value = ThisWorkbook.Sheets("SDF & ER").Range("A16").Value
.TextBox5.Value = ThisWorkbook.Sheets("SDF & ER").Range("C16").Value
.TextBox6.Value = ThisWorkbook.Sheets("SDF & ER").Range("A19").Value
.TextBox7.Value = ThisWorkbook.Sheets("SDF & ER").Range("A25").Value
.TextBox8.Value = ThisWorkbook.Sheets("SDF & ER").Range("A58").Value
.TextBox9.Value = ThisWorkbook.Sheets("SDF & ER").Range("B7").Value
.TextBox10.Value = ThisWorkbook.Sheets("SDF & ER").Range("E7").Value
.TextBox11.Value = ThisWorkbook.Sheets("SDF & ER").Range("A28").Value
.TextBox12.Value = ThisWorkbook.Sheets("SDF & ER").Range("B30").Value
.TextBox13.Value = ThisWorkbook.Sheets("SDF & ER").Range("C64").Value
.TextBox14.Value = ThisWorkbook.Sheets("SDF & ER").Range("H55").Value
.TextBox15.Value = ThisWorkbook.Sheets("SDF & ER").Range("A22").Value
.TextBox16.Value = ThisWorkbook.Sheets("SDF & ER").Range("G7").Value
.SaveAs Filename:="\\Toolbox\bulletinboard\" & ThisWorkbook.Sheets("SDF & ER").Range("J7").Value & ".htm", FileFormat:=wdFormatHTML
End With
End Sub
Reply With Quote