View Full Version : [SOLVED:] VBA Code to Save into a Network Drive
EdwardOcampo
06-23-2017, 04:46 AM
Hi!
Part of my code is not working. The part that is not working is saving the file into an specific file in a network drive.
Here is the VBA that I'm using.
ChDir "G:\NARS Planning\Open Order Reports"
ActiveWorkbook.SaveAs Filename:="NARS Open Order Report " & Format(Date, "mm.dd.yy") & ".xlsx", FileFormat:=xlOpenXMLWorkbook
Any input will be greatly appreciated.
Thank you.
:dunno: Try
Dim ThePath As String
ThePath = "G:\NARS Planning\Open Order Reports"
ActiveWorkbook.SaveAs Filename:=ThePath & "NARS Open Order Report " & Format(Date, "mm.dd.yy") & ".xlsx", FileFormat:=xlOpenXMLWorkbook
BTW, I usually save my files with a date stamp format of Year Month Day, so they list in Date order.
Yours will be listed like
Jan 1 1950
Jan 1 1951
Jan 1 1952
etc
Jan 2 1950
Jan 2 1951
Etc, etc, etc
Feb 1 1950
Feb 1 1951
Bob Phillips
06-24-2017, 06:51 AM
You are missing a path separator
Dim ThePath As String
ThePath = "G:\NARS Planning\Open Order Reports"
ActiveWorkbook.SaveAs Filename:=ThePath & Application.PathSeparator & "NARS Open Order Report " & Format(Date, "mm.dd.yy") & ".xlsx", FileFormat:=xlOpenXMLWorkbook
or
Dim ThePath As String
ThePath = "G:\NARS Planning\Open Order Reports" & Application.PathSeparator
ActiveWorkbook.SaveAs Filename:=ThePath & "NARS Open Order Report " & Format(Date, "mm.dd.yy") & ".xlsx", FileFormat:=xlOpenXMLWorkbook
EdwardOcampo
06-29-2017, 07:48 AM
Thank you both for your efforts. AT XLD; AT SAMT
It worked!!
Edward.
You are missing a path separator
Dim ThePath As String
ThePath = "G:\NARS Planning\Open Order Reports"
ActiveWorkbook.SaveAs Filename:=ThePath & Application.PathSeparator & "NARS Open Order Report " & Format(Date, "mm.dd.yy") & ".xlsx", FileFormat:=xlOpenXMLWorkbook
or
Dim ThePath As String
ThePath = "G:\NARS Planning\Open Order Reports" & Application.PathSeparator
ActiveWorkbook.SaveAs Filename:=ThePath & "NARS Open Order Report " & Format(Date, "mm.dd.yy") & ".xlsx", FileFormat:=xlOpenXMLWorkbook
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.