File Not Saving

Skybluekid

Well-known Member
Joined
Apr 17, 2012
Messages
1,224
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I am using the below code:
VBA Code:
Sub SaveSheetasFile()

Dim Masterfile As Workbook
Dim NewWb As Workbook
Dim Rng As Range
Dim Filename As String

Set Masterfile = ThisWorkbook
Set NewWb = Workbooks.Add
Set Rng = Masterfile.Sheets(2).Range("B2:K41")

Filename = "FakePath & Masterfile.Sheets(2).Range("R2").Text

'Copy Range and Paste onto ActiveSheet
Rng.Copy Destination:=NewWb.Sheets(1).Range("B2")

'Adjust Columns
Columns("B").ColumnWidth = 9.71
Columns("C").ColumnWidth = 9.71
Columns("D").ColumnWidth = 12.14
Columns("E").ColumnWidth = 12.71
Columns("F").ColumnWidth = 11.29
Columns("G").ColumnWidth = 36.29
Columns("H").ColumnWidth = 52.86
Columns("I").ColumnWidth = 11.57
Columns("J").ColumnWidth = 10.57
Columns("K").ColumnWidth = 21.14

ActiveSheet.Shapes.Range(Array("Picture 5")).Select
    Selection.ShapeRange.ScaleWidth 1.0687910655, msoFalse, msoScaleFromTopLeft
    Selection.ShapeRange.ScaleHeight 0.4065694608, msoFalse, msoScaleFromTopLeft
   
With ActiveWorkbook
    .SaveAs Filename, xlOpenXMLWorkbook
    .Close
End With

End Sub

It works until until I get to save the file, where is comes up with a Runtime Error 1004 Method 'Save As' of Object'_Workbook' Failed

I have looked at everything I can think of, but with no joy.

Any help would be appreciated

Thanks in Advance
 
Last edited by a moderator:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I'm guessing....
Code:
Filename = "FakePath & "\" & Masterfile.Sheets(2).Range("R2").Text
HTH. Dave
 
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

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