Method 'SaveAs' of object '_Workbook' failed

queenvee

New Member
Joined
Oct 30, 2017
Messages
4
Hello,

I am a basic excel user who is just learning to do a few simple things in VBA and only through information I have found in searches (like adding auto-complete to a dropdown list). My company just moved their server and now a form a previous employee wrote is not functioning properly. I assumed it was a reference to the server location, but am out of my depth - I changed the thisfile= path and it did not correct the issue (the error is the title of my post). The line starting with ActiveWorkbook is highlighted in yellow when I debug. I would be grateful for any help offered to correct this. :) Please let me know if I need to provide additional details.

The code is:

Public Sub SaveAsA1()
Application.DisplayAlerts = False
Dim thisfile As String, newname As String
newname = Range("s3") & " " & Range("m3").Value
thisfile = "\\43server\orders" & newname
ActiveWorkbook.SaveAs Filename:=thisfile, FileFormat:=51
Application.DisplayAlerts = True
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try
Code:
thisfile = "\\43server\orders[COLOR=#ff0000]\[/COLOR]" & newname
 
Upvote 0
I entered the new server path location and that solved the problem. Thank you!!

After that works, now there is another button to fix, which copies a line of data to a shipping log. I assumed it was a similar issue of pointing to the new server path location, but it is not as clear to me with this error: Runtime error 9 - subscript out of range. The highlighted line is: Windows("Shipping log (Autosaved)1.xlsx").Activate

again - any help is appreciated :)

Sub Copyshipping()
'
' Macro1 Macro
'


'
Range("ad15:ah15").Select
Selection.Copy
Windows("Shipping log (Autosaved)1.xlsx").Activate
lMaxRows = Cells(Rows.Count, "c").End(xlUp).Row
Range("c" & lMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False



End Sub
 
Upvote 0
Is that file open when you run the macro?
 
Upvote 0
Yes the file is open. The sequence is the userexecutes the first button, which saves the template as an xlsx file in the location (which we just fixed). Then they select the second button which copies and pastes a specific line of data to the next open line on the shipping log (a separate xlsx file).
 
Upvote 0
With the shipping log as the active workbook run this & what does it say
Code:
Sub chk()
MsgBox "|" & ActiveWorkbook.Name & "|"
End Sub
 
Upvote 0
Sub chk()
MsgBox "|" & ActiveWorkbook.Name & "|"
End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)


End Sub
 
Upvote 0
What did the message box say when you ran Chk?
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

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