Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2007
    Posts
    93

    Unanswered: excel automation

    hello freinds !!

    i am doing excel automation from access
    i am copying one excel sheet through automation

    but when i am copying the sheet .. i am loosing the format like merge cell option.

    here is my code

    with object
    wksXL1.Activate
    wksXL1.Cells.Select
    appXL1(object1).Selection.Copy
    wksXL(object2).Activate
    wksXL(object2).Pastespecial
    end obj


    i have the concept but have no clue y its not working

    any suggestiosn would be appreciated
    thanks

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    My guess would be that PasteSpecial has a few arguments you should fill in.
    The default is probably "Values", and you want to see "All"
    Inspiration Through Fermentation

  3. #3
    Join Date
    Nov 2007
    Posts
    93

    excel autimation

    thanks for the reply

    i have tried using paste special options
    like
    obj.pastespecial xlvalues:=all blah blah

    but nothing seems to be working

  4. #4
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Yeah, the help file for that topic doesn't tell you much, either.

    Have you tried doing it by recording your actions into a macro, to see how Excel thinks it should be done? That usually at least points me in the right direction.
    Inspiration Through Fermentation

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Why not just Paste instead of PasteSpecial?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    Nov 2007
    Posts
    93

    excel automation

    thanks for the reply
    i have tried bth the ways i.e paste and pastespecial. and even i tried with breaking up paste special options..

    but nothing seems tobe working for me ...
    half of the stuff gets formatted and rest of it doesnt .. dont know y ..
    the problem is with the cell merging i believe...
    for instace like a1,a2a3 is merged then its working like its considering only a1 and a2 and a3 are left out !!

    hope u guys can help me out !!

    thanks

  7. #7
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    I tested this on my machine and it copied everything properly.
    You may be using the wrong objects...Workbook vs Worksheet

    Code:
        Range("A1:B4").Select
        Selection.Copy
        Sheets("Sheet2").Select
        Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=False
    Inspiration Through Fermentation

Posting Permissions

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