Results 1 to 3 of 3

Thread: Copy/Paste from Excel to Word

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    3

    Copy/Paste from Excel to Word

    Thanks in advance for any help ...

    Have code that creates a Workbook with 2 worksheets based on user input. The 2 sheets are Input and Output. From the Output worksheet, a certain range for a certain year (within each year, each quartile) is copied and pasted into Word as a metafile. Oddly enough, only the year 2000 is skipped and not copied into MS Word as a metafile and can't figure out why. Code is kinda long, so is attached.

    Any assistance, well appreciated.
    Attached Files Attached Files

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

    Re: Copy/Paste from Excel to Word

    Thats allot of code to go through but good for referencing your issue. Could you place a breakpoint at the "Do While Year < 2005" line and run it through until the Year is 2000. Then step through the code and see if it skips any loops or generates any unseen errors.
    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    3

    Re: Copy/Paste from Excel to Word

    RobDogg -

    Stepped through the code and I think what is happening is this - I have defined a maximum number of records (rows) to be pasted as a metafile in Word as this is generally the optimum number of records to be displayed per page. But when the returned records are greater than the max defined, Word isn't sure what to do with them so it skips and continues with the loop.

    So I'm wondering if there is a way to set a condition wherein if the number of returned records are greater than the maximum defined, the pasted metafile is proportionally re-sized to fit on one page.

    Thanks again for any assistance.

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