Results 1 to 21 of 21

Thread: copying data from excel to word

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    copying data from excel to word

    HI!!
    how can i copy all data from excel to word along with the cells?

    Thanks and Regards
    Vivek.s

  2. #2
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: copying data from excel to word

    i just did a little test in excell and word, i saved a .xls file and oppened it in word, and it oppened succesfully!

    so what do you mean?

    PS: unless you plan on somehow making a poject relating to this subject please dont cross-thred
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: copying data from excel to word

    hi!
    can u post that code.........?

    thanks and regards
    vivek.s

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: copying data from excel to word

    just save it in excel, and open it in word. no code required.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: copying data from excel to word

    hi sorry........i wud like to copy data in sheet1 along with the cells(in a table) using my vb code.....

    regards
    vivek.s

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: copying data from excel to word

    my copy of word will open spreadsheets.

  7. #7
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: copying data from excel to word

    why dont you just use:
    Shell("C:\Program Files\Microsoft Office\Office\WINWORD.EXE book1.xls")
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: copying data from excel to word

    hi!
    i opened excel from word but i get following output

    Code:
     †††††††††††††††††††††††††††††††††††††††††††††††††††B
    †††††††††††††††††††††††††††††††††††††††††††††††††††䈠Ȁ
    1㐱㔹㠠†††††††††††††††††††††††††††††††††††††††††††††††††††䈀Ȁ
    Arial1
    Arial1
    Arial1
    Arial1
    "$"#,##0_);\("$"#,##0\)
    "$"#,##0_);[Red]\("$"#,##0\)
    "$"#,##0.00_);\("$"#,##0.00\)
    "$"#,##0.00_);[Red]\("$"#,##0.00\)
    _("$"* #,##0_);_("$"* \(#,##0\);_("$"* "-"_);_(@_)
    _(* #,##0_);_(* \(#,##0\);_(* "-"_);_(@_)
    _("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)
    _(* #,##0.00_);_(* \(#,##0.00\);_(* "-"??_);_(@_)à
    Sheet1
    Sheet2
    Sheet3
    RECIEPT NUMBER
    EMAIL ID
    PASSPORT NUMBER
    APPOINTMENT DATE ( mm-dd-yyyy)
    while my desired output is

    RECIEPT NUMBER
    EMAIL ID
    PASSPORT NUMBER
    APPOINTMENT DATE ( mm-dd-yyyy)

    in a table..........

    regards
    vivek.s

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: copying data from excel to word

    anyways to do this?

    thanks and regards
    vivek.s

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: copying data from excel to word

    post it, and we'll take a look. you may have to copy/paste it into word.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: copying data from excel to word

    hi
    i have to do it using my VB program and data in excel shud be pated in a table in word.......

    regards
    vivek.s

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: copying data from excel to word

    just open excel, copy the cells, open word and paste them.

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: copying data from excel to word

    Sup vivek. You can insert an Excel workbook into a Word document like
    below. Change the parameters if you want a linked object, etc.

    VB Code:
    1. 'Word application
    2. Application.Selection.InlineShapes.AddOLEObject ClassType:="Excel.Sheet.8", FileName:= _
    3. "D:\Book1.xls", LinkToFile:=False, DisplayAsIcon:=False
    Not sure if this is how you need it but I thought I would post it and find out.

    HTH
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: copying data from excel to word

    I started working on it once i realized noone else wants to takle this, (!!!NO OFFENCE!!!) and i got it to work sucessfully!!! just make a XLS called "Book1.xls" in drive C or just edit the code, and in the XLS put some data where ever, and then run this and it will make a file called "2.doc" on the C:\ and then open it and !Vwala!

    VB Code:
    1. Dim objExcel As Object
    2. Dim objWord As Object
    3. Set objExcel = CreateObject("excel.application")
    4. Set objWord = CreateObject("word.application")
    5. objWord.documents.Add
    6. objExcel.workbooks.open ("C:\book1.xls")
    7. objExcel.cells.Select
    8. objExcel.cells.Copy
    9. objWord.selection.Paste
    10. objWord.activedocument.saveas "C:\2.doc"
    11. Clipboard.Clear
    12. objExcel.quit
    13. objWord.quit
    14. Set objWord = Nothing
    15. Set objExcel = Nothing
    PS: FYI, it is really slow!
    Last edited by ALL; Jan 25th, 2005 at 02:15 AM.
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  15. #15
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: copying data from excel to word

    didn't you see RD's code? did you try it? (I didn't)

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: copying data from excel to word

    SUP GURU
    WOW!!
    THANKS A LOT GUYS!I'M GONNA TRY THESE OUT



    Thanks and Regards
    Vivek.s

  17. #17
    New Member
    Join Date
    Jan 2005
    Posts
    12

    Re: copying data from excel to word

    I tried the code.........its working well for the first sheet.........but how can i copy the contents from second sheet or 3rd sheet?

    Regards
    karthik

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: copying data from excel to word

    Quote Originally Posted by Karslive
    I tried the code.........its working well for the first sheet.........but how can i copy the contents from second sheet or 3rd sheet?

    Regards
    karthik
    Which posted code are you refering to?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  19. #19
    New Member
    Join Date
    Jan 2005
    Posts
    12

    Re: copying data from excel to word

    i used the code given by All.......and modified to work for different sheets...i used this code

    Set bk = objExcel.Workbooks.Open("C:\Book1.xls")
    Set sh = bk.Worksheets("Sheet3")
    sh.UsedRange.Copy

    Now i am facing a problem.......on how to insert a string into word using VB.......

    regards
    karthi

  20. #20
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: copying data from excel to word

    If your using Alls code then the next line would be this - objWord.selection.Paste,
    but you need his code to create the Word doc first.

    HTH
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  21. #21
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: copying data from excel to word

    i was going to add a thing so you could select what sheet to get data out of, but i figured i would keep it simple, it seems to work better usually
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

Posting Permissions

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



Click Here to Expand Forum to Full Width