Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 02-16-2014, 02:56 PM
CIF CIF is offline Run Time Error 4248 when opening Word Doc from Excel Windows 7 32bit Run Time Error 4248 when opening Word Doc from Excel Office 2007
Novice
Run Time Error 4248 when opening Word Doc from Excel
 
Join Date: Feb 2014
Posts: 7
CIF is on a distinguished road
Default

Thanks, Paul. I've highlighted the line where the error occurs. It only occurs sometimes though, so it seems to be some kind of timing thing.

Code:
Sub OCLayin_CreateQuote() 
     'Collect the Needed Information
    Dim myProject, myCompanyInfoL1, myCompanyInfoL2, myCompanyInfoL3, myQuoteNumber As String 
    Dim mycustomer, mydate As String, myuser As String, myDate1 As String, myDate2 As String, myDate3 As String 
    Dim myFileName As String 
    myProject = ActiveWorkbook.Sheets("Project Setup").Range("B4") 
    myCompanyInfoL1 = ActiveWorkbook.Sheets("Project Setup").Range("B8") 
    myCompanyInfoL2 = ActiveWorkbook.Sheets("Project Setup").Range("B6") & " - " & ActiveWorkbook.Sheets("Project Setup").Range("B7") 
    myCompanyInfoL3 = ActiveWorkbook.Sheets("Project Setup").Range("B5") 
    myQuoteNumber = ActiveWorkbook.Sheets("Project Setup").Range("E4") 
    mycustomer = ActiveWorkbook.Sheets("Project Setup").Range("B6") 
    mydate = ActiveWorkbook.Sheets("Project Setup").Range("E5") 
    myuser = ActiveWorkbook.Sheets("Project Setup").Range("E7") 
    myDate1 = ActiveWorkbook.Sheets("Project Setup").Range("A45") 
    Dim wrdApp As Word.Application 
    Set wrdApp = CreateObject("Word.Application") 
    Application.ScreenUpdating = False 
    With wrdApp 
        .Documents.Add Template:="G:\ABP\ArchSpec\A-Operations\Group Templates\Quote Templates\OpenCellQuote.dotx" 
        If .ActiveDocument.Bookmarks.Exists("Project") Then 
            .ActiveDocument.Bookmarks("Project").Range.Text = myProject 
        End If 
        If .ActiveDocument.Bookmarks.Exists("ToL1") Then 
            .ActiveDocument.Bookmarks("ToL1").Range.Text = myCompanyInfoL1 
        End If 
        If .ActiveDocument.Bookmarks.Exists("ToL2") Then 
            .ActiveDocument.Bookmarks("ToL2").Range.Text = myCompanyInfoL2 
        End If 
        If .ActiveDocument.Bookmarks.Exists("ToL3") Then 
            .ActiveDocument.Bookmarks("ToL3").Range.Text = myCompanyInfoL3 
        End If 
        If .ActiveDocument.Bookmarks.Exists("Date") Then 
            .ActiveDocument.Bookmarks("Date").Range.Text = mydate 
        End If 
        If .ActiveDocument.Bookmarks.Exists("User") Then 
            .ActiveDocument.Bookmarks("User").Range.Text = myuser 
        End If 
        If .ActiveDocument.Bookmarks.Exists("QuoteNo") Then 
            .ActiveDocument.Bookmarks("QuoteNo").Range.Text = myQuoteNumber 
        End If 
        If .ActiveDocument.Bookmarks.Exists("Esc") Then 
            .ActiveDocument.Bookmarks("Esc").Range.Text = myDate1 
        End If 
        If .ActiveDocument.Bookmarks.Exists("Table") Then 
            ThisWorkbook.Sheets("Quote OC Lay-in").Range("A11:H40").Copy 
            .Selection.GoTo What:=wdGoToBookmark, Name:="Table" 
            .Selection.Paste 
        End If 
        myFileName = myProject & " " & myQuoteNumber & "_" & mycustomer & " " & "Quote" & " " 
        With .Dialogs(wdDialogFileSummaryInfo) 
            .Title = myFileName 
            .Execute 
        End With 
        .Visible = True 
        .ActiveDocument.SaveAs ("G:\ABP\ArchSpec\Project Files\Quotes\2014\Premium\MW Open Cell\" & myFileName & Format(Date, "mm-dd-yy") & ".docx") 
    End With 
    Application.CutCopyMode = False 
    Application.ScreenUpdating = True 
End Sub

Last edited by macropod; 02-16-2014 at 03:01 PM. Reason: Added code tags & formatting
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Time Error 4248 when opening Word Doc from Excel Run-time Error 5174: Open Word Documents from Excel tinfanide Excel Programming 3 10-01-2013 07:35 AM
Run Time Error 4248 when opening Word Doc from Excel Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248 Joe Patrick Word VBA 2 01-30-2012 07:23 AM
Word Visual Basic error - run time error 504 crazymorton Word 11 01-13-2012 04:32 AM
Run Time Error 4248 when opening Word Doc from Excel MS Word - There was an error opening the file cookiegal Word 7 04-04-2011 12:37 AM
Error opening word from a doc. Davem501 Word 0 12-01-2009 02:10 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:10 AM.


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