Getting Run-time Error After Export ActiveSheet

Prasad K

Board Regular
Joined
Aug 4, 2021
Messages
189
Office Version
  1. 2016
  2. 2007
Platform
  1. Windows
Hi Excel Experts

i have getting run time error after i export activesheet as new workbook to given directory


it is run-time error message i have getting
-----------------------------------------------------
Run-time error'1004':

Method'SaveAs' of object'_Workbook' failed
-----------------------------------------------------


VBA Code:
Sub Export()
    ActiveSheet.Copy
    Answer = InputBox("Enter Name of New Workbook", "New Workbook")
    UserDirectory = InputBox("Please Enter Directory To Save This File | Enter Directory Like This C: ")
    ActiveWorkbook.SaveAs Filename:= _
    UserDirectory & "\" & Answer & ".xlsx", FileFormat:=51
End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi Excel Experts

i have getting run time error after i export activesheet as new workbook to given directory


it is run-time error message i have getting
-----------------------------------------------------
Run-time error'1004':

Method'SaveAs' of object'_Workbook' failed
-----------------------------------------------------


VBA Code:
Sub Export()
    ActiveSheet.Copy
    Answer = InputBox("Enter Name of New Workbook", "New Workbook")
    UserDirectory = InputBox("Please Enter Directory To Save This File | Enter Directory Like This C: ")
    ActiveWorkbook.SaveAs Filename:= _
    UserDirectory & "\" & Answer & ".xlsx", FileFormat:=51
End Sub
My Problem Have Been Solved

I Have Added (On Error Resume Next) in this Code
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,055
Latest member
excelhelp12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top