+ Reply to Thread
Results 1 to 12 of 12

Copy Excel data to Word fields and retain fields

Hybrid View

GCW esq Copy Excel data to Word... 12-03-2011, 11:47 AM
snb Re: Copy Excel data to Word... 12-03-2011, 12:26 PM
GCW esq Re: Copy Excel data to Word... 12-09-2011, 08:49 AM
snb Re: Copy Excel data to Word... 12-09-2011, 08:54 AM
GCW esq Re: Copy Excel data to Word... 12-09-2011, 08:29 PM
GCW esq Re: Copy Excel data to Word... 06-05-2012, 09:53 AM
snb Re: Copy Excel data to Word... 06-05-2012, 09:57 AM
GCW esq Re: Copy Excel data to Word... 06-05-2012, 11:59 AM
snb Re: Copy Excel data to Word... 06-05-2012, 12:28 PM
GCW esq Re: Copy Excel data to Word... 06-05-2012, 07:39 PM
AlvaroSiza Re: Copy Excel data to Word... 06-06-2012, 12:53 AM
GCW esq Re: Copy Excel data to Word... 06-06-2012, 10:31 AM
  1. #1
    Registered User
    Join Date
    11-25-2011
    Location
    Lilydale, Victoria, Australia
    MS-Off Ver
    2013 (365)
    Posts
    63

    Re: Copy Excel data to Word fields and retain fields

    Thanks, snb. I tried .fields.unlink again, and this time it decided to work. Hmmm...

    This has raised another issue or two, however. I see that doing that has also removed the fields from my Table of Contents (and probably page numbers) in my Word doc. I will need these later. So I tried to use your code (thanks) to see if I could just remove some of the fields, but I got the same error: "Variable not Defined" on "ActiveDocument". I am using Option Explicit in the code, and it's Office 2003.

    Also, I have used ".activate" about six times in my code, and "select" once (just to put focus into a particular cell before the code finished running). What should I use instead? (One of those .activates is just before .fields.update .fields.unlink)

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Copy Excel data to Word fields and retain fields

    Word contains some 'storyranges'; have a look in the helpfiles about them.
    You can restrict the unlinking to 1 or more of these storyranges.
    But why would you like to 'unlink' ?



  3. #3
    Registered User
    Join Date
    11-25-2011
    Location
    Lilydale, Victoria, Australia
    MS-Off Ver
    2013 (365)
    Posts
    63

    Re: Copy Excel data to Word fields and retain fields

    Quote Originally Posted by snb View Post
    But why would you like to 'unlink' ?
    One of the documents filled from VBA is the template of what will eventually be a large Word document. When filled from VBA, there is still a lot more work to do on the document. VBA only puts some helpful bits of information in there (names, addresses, correct pronouns, etc). After the document is completed, it gets formatted by admin staff. They have had trouble with other fields in documents - although these were a different type. The trouble has come when they want to modify something in one of the fields, and it breaks links to other fields in the document, and that causes errors. So I thought it would be best to remove DocVariables when it gets to that stage.

    You've got me thinking now, though. I wonder if DocVariables would give the same trouble. I'd better do some experimenting... or just wait till the thing is up and running, and see what happens.

    These documents are sometimes sent to clients as Word docs as well (rather than PDF). I wonder if there will be any issues there.

    Now, about not using .activate in VBA...?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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