Results 1 to 3 of 3

Thread: Macro problems

  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro problems

    I have the follown macro on my spreadsheet. When I do Tools/Macors etc. etc. The Macro will work. But if I try to add it to a command button that runs the macro it doesn't work. I get Run Time 1004.

    You cannot save the workboot with the same name as another open worksheet.


    Save Spreadsheet
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs FileName:="tabsproddatabaseEdgarSecurityMasterTerm 2001.xls", _
    FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
    ReadOnlyRecommended:=False, CreateBackup:=False
    Application.DisplayAlerts = True
    End Sub

  2. #2
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: Macro problems

    what version of Excel? When I test in Excel 2K I don't reproduce the problem.
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Macro problems

    What type of Button are you using, one from the Forms Toolbar, or one from Control ToolBox. If it is one from the control toolbox, did you just copy the code, including sub name, into the Private Sub CommandButton1_Click() event.

    If it is a control toolbox button does it read as follows :

    Private Sub CommandButton1_Click()
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs FileName:="tabsproddatabaseEdgarSecurityMasterTerm 2001.xls", _
    FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
    ReadOnlyRecommended:=False, CreateBackup:=Fals
    Application.DisplayAlerts = True
    End Sub

    If the above is not the problem, does the error message give any further info ?

    Andrew C

Posting Permissions

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