![]() |
|
![]() |
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]() 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 |
#2
|
||||
|
||||
![]()
Hi joe,
Your ActiveDocument refernce is ambiguous. Try: Code:
Dim ws As WorkSheet Set ws = ThisWorkbook.Sheets("SDF & ER") Dim objWord As Object Set objWord = CreateObject("Word.Application") objWord.Visible = True objWord.Documents.Open "//Toolbox/bulletinboard/EIP_template.doc" With objWord.ActiveDocument .TextBox1.Value = ws.Range("A13").Value .TextBox2.Value = ws.Range("J7").Value .TextBox3.Value = ws.Range("A10").Value .TextBox4.Value = ws.Range("A16").Value .TextBox5.Value = ws.Range("C16").Value .TextBox6.Value = ws.Range("A19").Value .TextBox7.Value = ws.Range("A25").Value .TextBox8.Value = ws.Range("A58").Value .TextBox9.Value = ws.Range("B7").Value .TextBox10.Value = ws.Range("E7").Value .TextBox11.Value = ws.Range("A28").Value .TextBox12.Value = ws.Range("B30").Value .TextBox13.Value = ws.Range("C64").Value .TextBox14.Value = ws.Range("H55").Value .TextBox15.Value = ws.Range("A22").Value .TextBox16.Value = ws.Range("G7").Value .SaveAs FileName:="//Toolbox/bulletinboard/" & ws.Range("J7").Value & ".htm", FileFormat:=wdFormatHTML End With
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Paul, thank you so much - that's perfect! You've been so helpful on this MB I wish there was something I could do in return. Every now and then I check to see if there's a question I can answer to "pay it forward" but someone always beats me to it! Have a good one!
|
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Frankwlc | Word | 5 | 11-28-2011 01:54 AM |
![]() |
curatorfm | Mail Merge | 1 | 03-20-2011 04:26 AM |
Word Fill-in form with Excel spreadsheet | karik | Word | 0 | 01-11-2010 08:45 AM |
Runtime error 5487 - Word cannot complete the save to to file permission error | franferns | Word | 0 | 11-25-2009 05:35 AM |