Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Late binding

Status
Not open for further replies.

davefish

Technical User
Jul 26, 2002
169
GB
I have a few Excel programs running in Excel 2010, but will not run in Office 365 Excel 16 due to reference library issues. Can I just change the highlighted code below? Heklprequired please



Code:
Sub ExportQuoteToWord725()
'Opens document template and fills out fields to create a quotation document for sales.
'Document template (QuoteP725.dotx) must be in the same folder as this spreadsheet.
'Rev 0 - Initial version
Dim aCell As Cell
Dim r As Long
 Dim c As Long
 Dim R1 As Integer


Dim myPath As String
myPath = ActiveWorkbook.Path 'Get location of current spreadsheet

If Dir(myPath & "\QuoteP725.dotx") = "" Then 'Quote template does not exist
    MsgBox ("Put quote template (QuoteP725.dotx)" & vbCrLf & "into same folder as this spreadsheet")
    Exit Sub
Else
    
    [highlight #FCE94F]Dim wordApp As Word.Application
    Dim wordDoc As Word.Document
[/highlight]    
    
    Application.ScreenUpdating = False 'Hide sheet selections from user
        
    Sheets("Advanced cost calculator").Select   'Take all information from this sheet
    
    
                          
    On Error Resume Next
        Set wordApp = GetObject(, "Word.Application")       'Check if Word is open already
        If Err.Number <> 0 Then                            'Word isn't already running
            Set wordApp = CreateObject("Word.Application")  'Create new instance of an MS Word app
        End If
    On Error GoTo 0
    wordApp.Visible = True                          'Show newly-created MS Word object

    Set wordDoc = wordApp.Documents.Add(myPath & "\QuoteP725.dotx")  'Open up quotation template file from current folder

    '********************************************
    '*                                          *
    '* This macro replaces contents of cells in *
    '* a table in the word document             *
    '*                                          *
    '********************************************
    'Populate first column with product code
    
    wordDoc.Tables(4).Cell(2, 1).Range.Text = "    " & Range("O19").Value & "   Way Flush Mounting, Programmable Alarm Annunciator." 'Product code
    wordDoc.Tables(4).Cell(5, 1).Range.Text = Range("O25").Value 'Window size
    wordDoc.Tables(4).Cell(8, 1).Range.Text = Range("O13").Value & "W" & Range("O14").Value & "H" 'Panel Size
    wordDoc.Tables(4).Cell(12, 1).Range.Text = Range("O26").Value 'Pushbutton
    wordDoc.Tables(4).Cell(14, 1).Range.Text = Range("O19").Value & "A" 'Channel Count
    wordDoc.Tables(4).Cell(15, 1).Range.Text = Range("P24").Value ' Unarmed
    wordDoc.Tables(4).Cell(16, 1).Range.Text = Range("R25").Value 'Illumination
 
Hi,

Declare them As Object

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Hi Skipo,

I tried changing the code as shown below, but got an error on the highlighted point. unfortunately I don't have immediate access to a machine with Excel 2016, so can't pursue any further action
Code:
If Dir(myPath & "\QuoteP725.dotx") = "" Then 'Quote template does not exist
    MsgBox ("Put quote template (QuoteP725.dotx)" & vbCrLf & "into same folder as this spreadsheet")
    Exit Sub
Else
    
    Dim wordApp As Object
    Dim wordDoc As Object
    
    
    Application.ScreenUpdating = False 'Hide sheet selections from user
        
    Sheets("Advanced cost calculator").Select   'Take all information from this sheet
    
    
                          
    On Error Resume Next
        Set wordApp = GetObject(, "Word.Application")       'Check if Word is open already
        If Err.Number <> 0 Then                            'Word isn't already running
            Set wordApp = CreateObject("Word.Application")  'Create new instance of an MS Word app
        End If
    On Error GoTo 0
    wordApp.Visible = True                          'Show newly-created MS Word object

    Set wordDoc = wordApp.Documents.Add(myPath & "\QuoteP725.dotx")  'Open up quotation template file from current folder

    '********************************************
    '*                                          *
    '* This macro replaces contents of cells in *
    '* a table in the word document             *
    '*                                          *
    '********************************************
    'Populate first column with product code
    
    [highlight #FCE94F]wordDoc.Tables(4).Cell[/highlight](2, 1).Range.Text = "    " & Rang

Have I missed something as I'm not up to speed with Early Binding

Regards

DaveFish
 
Error message?

Perhaps you have less than 4 tables.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top