Transfer information from Word to Excel using VBA

  • Hi all,


    I was ondering if I could get some help. I am trying to find a way of transferring data from a word document into specific cells in excel. I have previously transferred data from excel to word using the following method:



    I wrongly assumed if you switch it around a bit like the following, it would do the job but this wasn't the case:



    However, this has not worked. It opens the document and I don't get an error message but nothing seems to actually transfer...


    Any ideas? of maybe a different code that might actually word?


    Thanks in adavance for your help.


    Cheers,

  • Re: Transfer information from Word to Excel using VBA


    Is that '[COLOR="#FF0000"]oo[/COLOR]bjWord.Documents...' a typo? There doesn't seem to be anything wrong with the code.


    I guess you do not have an

    Code
    Option Explicit

    statement at the top of the module, so learn a lesson from this...


    In the VBA Dev environment, go to the Tools/Options menu. From the first tab (Editor), select the 'Require Variable Declaration' option.


    This requires you to declare variables before they are used, any undeclared variables (or misspelt variables) will be flagged as an error, so prevents this type of issue.

  • Re: Transfer information from Word to Excel using VBA


    Hi,


    Yep... just a typo. I agree that there doesn't seem anything wrong. I'm not quite sure why it isn't working. I don't get an error message and everything seems to work fine but when you go onto the spreadsheet, the data hasn't transferred.

  • Re: Transfer information from Word to Excel using VBA


    I know this seems weird because it is essentially the same thing but can you post your code that works... I still don't get why it's not transferring the data. Unless it's transferring it to somewhere, I don't know about.

  • Re: Transfer information from Word to Excel using VBA


  • Re: Transfer information from Word to Excel using VBA


    Cheers for that!


    Still not working. No idea why not. I don't get an error message, so in theory it has worked. It works fine transferring from Excel to Word, so it can't be the document or a connect between word and excel. So I am confused by the whole thing...

  • Re: Transfer information from Word to Excel using VBA


    Thanks again... The only differece I can work out or see is that in the word document you've created the bookmark is at the beginning and end of the word or phrase whereas when I add a bookmark it is just at the beginning. Not sure how to change that!

  • Re: Transfer information from Word to Excel using VBA


    Yeah... that's it. Bracketed bookmarks is causing my problem. Not sure how I will sort it but I am sure there is a way.


    Thanks for your help though... it's much appreciated.

  • Re: Transfer information from Word to Excel using VBA


    They're called 'Enclosing Bookmarks'. The text associated with the bookmark is fully enclosed by the Start/End Bookmark 'markers'. If you cannot extend the selection to a logical end (of word, sentence or paragraph) then you'll have to delete and rebuild the bookmarks so they enclose the text.

  • Re: Transfer information from Word to Excel using VBA


    Thanks Cyptop, your help has been brilliant. You've gone above and beyond.


    I thought I had the hit jackpot with your link, but I can't seem to get it to work. I have posted a new thread that is more specific to actual issue I am now facing, but thanks for helping me work out the issue.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!