Results 1 to 3 of 3

Macro not finding all Word fields

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365 Version 2501 64-bit
    Posts
    1,465

    Macro not finding all Word fields

    Attached Word doc and Excel database need to be in same Folder.

    Word has twenty three fields, but Macro below is copying only twelve into the Database, and inserting a blank column between each for some reason?

    Option Explicit
    Dim wordApp As Word.Application
    Dim wDoc As Word.Document
    Dim i, n As Integer
    
    Sub DATAFROMWORD()
    
    Set wordApp = CreateObject("word.application")
    Set wDoc = wordApp.Documents.Open(ThisWorkbook.Path & "/" & Range("E1").Value & ".docx")
    wordApp.Visible = True
    
    With Sheet2
    n = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
    
    For i = 1 To 23
    
    Sheet2.Cells(n, i) = wDoc.ContentControls(i).Range.Text
    i = i + 1
    
    Next i
    
    End With
    
    wordApp.Documents.Close
    wordApp.Quit
    
    End Sub
    Hopefully someone will spot the problem?

    All solutions, suggestions and alternatives welcome as ever.

    Ochimus
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Formula Help Pls - Search cell for WORD, return fields from WORD lookup
    By tomski777 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-17-2017, 12:02 AM
  2. [SOLVED] Macro for finding specific Word and Deleting it
    By Haidar123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-02-2014, 07:45 AM
  3. Excel fields to a Word document set of fields?
    By brucemc777 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-06-2014, 02:09 PM
  4. Copy Excel data to Word fields and retain fields
    By GCW esq in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-06-2012, 10:31 AM
  5. Error with macro to open Word doc and copy fields
    By Greed in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-23-2011, 02:19 PM
  6. export cell contents to Word fields in a protected Word document
    By duugg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2011, 09:31 AM
  7. [SOLVED] Finding current cell row in spreadsheet from Word macro
    By boswellgw@hotmail.com in forum Excel General
    Replies: 3
    Last Post: 07-07-2005, 08:05 PM

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