Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-23-2012, 01:31 PM
Joe Patrick Joe Patrick is offline Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248 Windows 7 64bit Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248 Office 2007
Advanced Beginner
Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248
 
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
  #2  
Old 01-26-2012, 07:14 PM
macropod's Avatar
macropod macropod is offline Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248 Windows 7 64bit Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 01-30-2012, 07:23 AM
Joe Patrick Joe Patrick is offline Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248 Windows 7 64bit Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248 Office 2007
Advanced Beginner
Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248
 
Join Date: May 2011
Posts: 33
Joe Patrick is on a distinguished road
Default

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!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248 Runtime Error 4120 in Word 2007 macro Frankwlc Word 5 11-28-2011 01:54 AM
Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248 Merge excel info into word letter. 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:44 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft