+ Reply to Thread
Results 1 to 2 of 2

Copy Sheet and Macro without linking to old sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    09-18-2008
    Location
    Switzerland
    MS-Off Ver
    Office 2003
    Posts
    82

    Copy Sheet and Macro without linking to old sheet

    Hi,

    With a macro I copy a sheet out of the workbook and create a new one.
    I then want this new sheet to have the following macro:
    Private Sub Mail()
    
        Dim olApp As Outlook.Application
        Dim olMail As Outlook.MailItem
        
        On Error Resume Next
        Set olApp = GetObject(, "Outlook.Application")
        If Err.Number <> 0 Then
            Set olApp = CreateObject("Outlook.Application")
            Err.Clear
        End If
        On Error GoTo 0
        
        Set olMail = olApp.CreateItem(olMailItem)
        
        With olMail
            .Subject = Range("A1") & " " & Range("A3")
            .To = Range("A8")
            .CC = Range("A9")
            .Attachments.Add ThisWorkbook.FullName
            .Display
        End With
    
    End Sub
    Until now I have a userform that gets copied as well.
    But it will then refer to and also attach the old workbook, how can I change that ? Since the new workbook has a naming policy (date, name etc) it's never the same and cannot be used directly.
    Last edited by Simon-ch; 01-19-2009 at 11:17 AM.

  2. #2
    Registered User
    Join Date
    09-18-2008
    Location
    Switzerland
    MS-Off Ver
    Office 2003
    Posts
    82
    Ok, I solved the problem by using a cmdbutton instead of a userform.
    But my problem now is that the outlook object library in the generated version isn't enabled, why doesn't it copy these settings, because the source workbook has it enabled ?

+ 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