+ Reply to Thread
Results 1 to 3 of 3

Debug: Run-time error '438'

Hybrid View

  1. #1
    Registered User
    Join Date
    05-27-2013
    Location
    Middle, Nowhere
    MS-Off Ver
    Excel 2003
    Posts
    13

    Debug: Run-time error '438'

    Hi guys,

    everytime I run this macro I will always get the Run-time error '438': Object doesn't support this property or method. Can someone help me debug this because I have no clue how to fix this?

    If it can't be fixed, I'm basically trying to copy text from excel to word, use the replace function to reformat, and copy and paste the newly formatted text from word to excel.
    Sub modulenter()
    
    Dim appWD As Word.Application
        Dim Name As String
        Set appWD = CreateObject("Word.Application")
        appWD.Visible = False
    
    
        Sheets("Sheet1 (2)").Select
        FinalRow = Range("F9999").End(xlUp).Row
        For i = 2 To FinalRow
        j = Sheets("MasterList").Cells(Rows.Count, 1).End(xlUp).Row
        Sheets("MasterList").Cells(j, 1).Value = Sheets("Sheet1 (2)").Cells(i, 3).Value
            Sheets("Sheet1 (2)").Select
            Cells(i, 6).Copy
            ' Tell Word to create a new document
            appWD.Documents.Add
            ' Tell Word to paste the contents of the clipboard into the new document
            appWD.Selection.Paste
            ' Save the new document with a sequential file name
            appWD.Selection.Find.Replacement.ClearFormatting
            With appWD.Selection.Find
            
                .Text = "@"
                .Replacement.Text = "^n"
                .Forward = True
                .Wrap = wdFindContinue
                .Format = False
                .MatchCase = False
                .MatchWholeWord = False
                .MatchWildcards = False
                .MatchSoundsLike = False
                .MatchAllWordForms = False
        End With
        appWD.Selection.Find.Execute Replace:=wdReplaceAll
        appWD.Selection.WholeStory
        appWD.Selection.Cut
        Sheets("Masterlist").Cells(j, 2).Selection.Paste
        appWD.ActiveDocument.WholeStory
        appWD.Selection.delete
        
        appWD.ActiveDocument.Close
        
        
        
        
        
        Next i
        ' Close the Word application
        appWD.Quit
    End Sub
    Thanks!

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Debug: Run-time error '438'

    Well you probably need to change that line to Sheets("Masterlist").Cells(j,2).Pastespecial

    But, why not use VBA's replace function:
    cells(j,2) = replace(cells(i,6),"@","^n")

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Debug: Run-time error '438'

    Replace this line

    Sheets("Masterlist").Cells(j, 2).Selection.Paste


    With

    Sheets("Masterlist").Cells(j, 2).PasteSpecial xlPasteAll


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Run Time Error in coding - Can someone help me debug please?
    By DMacSTB in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-31-2013, 09:30 AM
  2. [SOLVED] Run Time Error Debug help
    By AutoCAD Guy in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-16-2013, 09:44 AM
  3. Excel 2010 (Run-time error '13' type mismatch) "Debug" and "Continue" Grayed out.
    By Jeronimo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2012, 06:42 PM
  4. Replies: 3
    Last Post: 03-29-2012, 01:58 PM
  5. debug error?
    By mitelkm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2008, 01:27 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1