+ Reply to Thread
Results 1 to 8 of 8

Import text fields from Word

  1. #1
    Registered User
    Join Date
    10-31-2011
    Location
    Bel Air, Maryland
    MS-Off Ver
    Excel 2007 / 2010
    Posts
    3

    Import text fields from Word

    ALCON,
    This is my first post; please excuse my ignorance if I posted in the wrong place...blame it on my age.
    BLUF: Bottom Line Up Front, I Import text fields from MS Word forms when they're filed. I have the importing working, but upon running macro to update/import new forms they overwrite my previous data...Example: I import 3 forms, data is place in rows a2, a3, a4 and i save...when i import new forms the data overwrites a3, a4 etc...

    This is my code:

    Please Login or Register  to view this content.
    Any help for this retired veteran would be much appreciative.
    Richard

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Import text fields from Word

    Welcome to the forum!

    It is easier to debug code if you indent it for structure. Select and Activate are seldom needed.

    try:
    Please Login or Register  to view this content.

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

    Re: Import text fields from Word

    or faster:

    Please Login or Register  to view this content.
    Last edited by snb; 10-31-2011 at 04:31 PM.



  4. #4
    Registered User
    Join Date
    10-31-2011
    Location
    Bel Air, Maryland
    MS-Off Ver
    Excel 2007 / 2010
    Posts
    3

    Re: Import text fields from Word

    Mr. Hobson,
    I tried your revised code; it ran, but my results were the same. I placed new documents into my unprocessed folder and imported them, the new data started at A3 and overwrote my old data instead of importing the new data on the next empty cell (row).

    snb,
    when i ran your code I received a bug at line:
    Name c00 & c01 As replace(c00 & c01," Un","")

    I hope everyone understands my intent: If I place 3 forms in my unprocessed folder, then import them, they need to populate in rows A2, A3, A4. When I place new forms in the folder (4ea), when imported they should be place in rows A5, A6, A7, A8...this is not happening.

    Thx for help fellas,
    Richard

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

    Re: Import text fields from Word

    You must have an extraordinary system; I never receive bugs (it seems I produce them myself ). What I do get is an error message.
    I assumed the folder
    "C:\Documents and Settings\richard.b.rivera\Desktop\dart Processed\"
    exists.

    Try this amended code

    Please Login or Register  to view this content.

  6. #6
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Import text fields from Word

    Your modified code that I first posted worked fine for me. I wonder if you know how UsedRange works? If you count the rows, it can be misleading. Always put some value in row 1 before using UsedRange to count rows unless you know the number of preceding blank rows. Normally, I just count the last row based on the last value in Column A.

    This is the same code but a bit easier to set the in and out paths. I commented out the Activate sheet line since I ran it on the activesheet.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-31-2011
    Location
    Bel Air, Maryland
    MS-Off Ver
    Excel 2007 / 2010
    Posts
    3

    Re: Import text fields from Word

    The code did work; I had forgotten to place a value in A1. Thx for all the help guys...one last question. What do I place in the code to also pull in data from my drop-down list? It's just pulling the text fields...

    Again, thx for the help.
    Richard

  8. #8
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Import text fields from Word

    That is what you told it to do with:
    Please Login or Register  to view this content.
    Look at the help for wdFieldType in Word's VBA and we see:
    wdFieldFormDropDown = 83, FormDropDown field.

    So, we would change the line of code to:
    Please Login or Register  to view this content.

+ 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