+ Reply to Thread
Results 1 to 2 of 2

Problem copying/pasting worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    12-07-2004
    Posts
    5

    Problem copying/pasting worksheet

    I'm trying to copy the active sheet in an open workbook to a new workbook and save it. Below code is used:

    name = ActiveSheet.name
    path = "C:\"

    Set fmWkBook = Application.ActiveWorkbook
    fmWkBook.Worksheets(ActiveSheet.name).Copy

    Set toWkBook = Application.ActiveWorkbook
    With toWkBook
    .SaveLinkValues = False
    .UpdateRemoteReferences = False
    ' Save the Workbook
    .SaveAs FileName:=path & name, FileFormat:=xlNormal
    .Close
    End With
    Set toWkBook = Nothing


    I have two problems.

    1. It always asks "Save Book1 with references to unsaved documents?"

    2. It doesn't always get the active sheet (ie. the sheet showing on the screen). It sometime gets a sheet on another tab.

    I'm using Excel 2000.

    Thanks
    Rut

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Rut

    I don't know if it will help with your specific problem but try this.
    Dim ws As Worksheet
    Dim toWkBook
    Application.DisplayAlerts = False
    Set ws = ActiveSheet
    Path = "C:\"
    
    ws.Copy
    
    Set toWkBook = Application.ActiveWorkbook
    
    With toWkBook
        .SaveLinkValues = False
        .UpdateRemoteReferences = False
        .SaveAs Filename:=Path & Name, FileFormat:=xlNormal
        .Close
    End With
    
    Application.DisplayAlerts = True
    
    Set toWkBook = Nothing

+ 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