First timer: Saving a file on a network drive

assassin3212

New Member
Joined
Mar 23, 2011
Messages
1
Hello everyone

I am pretty handy in Excel but have just started to dip my toes into VBA.

I have created a sheet where the user inputs their name in cell A1, and the date in DDMMYYYY format in cell 2. I then have a hidden cell (D40) with CONCATENATE formula to pull both of the above figures into one cell. I'd like to use this value as the file name when saving which will be saved in a folder on my Company's network drive. I'd like to add a button to do the below:

- 'Save As' the file on the shared area of the network:
//DFS/shared/finance_Monitoring_Software/FY11/New Attribute Values
- Save as with a file name of the value in cell D40
- Close the file down

I've come across the below on the 'net which does not seem to be working:

Sub SaveWithVariableFromCell()
SaveName = ActiveSheet.Range("D40").Text
ActiveWorkbook.Close Filename:="//DFS/shared/finance_monitoring_software/FY11/New Attribute Values" & SaveName & ".xls"
End Sub

Does the above look like it should work for me?

Huge thanks in advance
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

dantheman9

Board Regular
Joined
Feb 5, 2011
Messages
175
Have you set the SaveName as a String?

Code:
Sub SaveWithVariableFromCell()
 
Dim SaveName As String
 
SaveName = ActiveSheet.Range("D40").Text
ActiveWorkbook.Close Filename:="//DFS/shared/finance_monitoring_software/FY11/New Attribute Values" & SaveName & ".xls"
End Sub
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,833
Office Version
  1. 2010
Platform
  1. Windows
Looks to me like it's missing a path separator after Attribute Values. And you need write permission for the folder.

EDIT: And it should be

Code:
ActiveWorkbook[COLOR=red].SaveAs[/COLOR] Filename:=...
 
Last edited:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,651
Messages
5,854,959
Members
431,689
Latest member
jacker01

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
Top