VBA宏使用来自单元格的路径来保存excel文件 [英] VBA macro to save excel file using path from cell

查看:478
本文介绍了VBA宏使用来自单元格的路径来保存excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用硬线和单元格值的组合来保存文件来确定文件路径。



在单元格 A29 中,我有一个公式输出:


2014\January\High Cash 1.7.14


我正在



代码是:

  ActiveWorkbook.SaveAs文件名:=S:\IRD\Tamarac\Daily高现金报告和范围(A29)。文本&.xlsx,FileFormat: = _ xlNormal,Password:=,WriteResPassword:=,ReadOnlyRecommended:= False _,CreateBackup:= False 


解决方案

我将重写如下:

  Dim fileName As字符串
fileName =S:\IRD\Tamarac\Daily高现金报告和范围(A29)。文本&.xlsx
ActiveWorkbook.SaveAs文件名: = fileName,FileFormat:= xlNormal,Password:=,WriteResPassword:=,ReadOnlyRecommended:= False,CreateBackup:= False

我想你所缺少的是在代码的报告部分之后关闭双引号...


I'm trying to save out a file using a combination of hard line and cell value to determine the file path.

In cell A29, I have a formula that outputs this:

2014\January\High Cash 1.7.14

I'm getting an Expected: end of statement error.

The code is:

ActiveWorkbook.SaveAs Filename:="S:\IRD\Tamarac\Daily High Cash Reporting\& Range("A29").Text & ".xlsx", FileFormat:= _  xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False

解决方案

I would re-write as follows:

Dim fileName As String
fileName = "S:\IRD\Tamarac\Daily High Cash Reporting\" & Range("A29").Text & ".xlsx"
ActiveWorkbook.SaveAs Filename:=fileName, FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False

I think all you are missing is the closing double-quotes after the 'Reporting\' part of your code...

这篇关于VBA宏使用来自单元格的路径来保存excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆