VBA Save As not working.....

BrianG86

Board Regular
Joined
Nov 12, 2013
Messages
135
Hi,

I am trying to save a new workbook, but it will not work. Get a runtime 1004 error.

Can anyone help?

Code:
Sub test()

Dim wb As Workbook
Dim wb2 As Workbook
Dim ws As Worksheet
Dim dte As String
Set wb = ThisWorkbook
Set ws = wb.Sheets("Signed EUR")
dte = ws.Range("N28").Value
ws.Cells.Copy
Set wb2 = Workbooks.Add
wb2.Sheets(1).Cells(1, 1).PasteSpecial xlPasteValues
wb2.SaveAs Filename:="S:\QA\Clients\Insight\" & dte & ".xlsx", FileFormat:=xlNormal
 
End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
While I am no pro, I think the issue may be with the format you are saving as. You initially instruct to save in .xlsx, however later instruct to save as xlnormal (which I believe to be xls). I would suggest removing the xlNormal.

old
"wb2.SaveAs Filename:="S:\QA\Clients\Insight\" & dte & ".xlsx", FileFormat:=xlNormal"

new
wb2.SaveAs Filename:="S:\QA\Clients\Insight\" & dte & ".xlsx"

Regards
Gary Waddell
 
Upvote 0
Scratch that.

I have got rid of the slashes, but now getting the error message: "the specified dimension is not valid for the current chart type"
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,202
Members
448,554
Latest member
Gleisner2

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