Ser*_*gey 3 excel vba excel-vba
我使用以下代码以添加新工作簿,保存并命名工作簿(基于位于工作表中某个单元格中的日期).
Dim wb As Workbook
Dim wbName As String
wbName = ThisWorkbook.Sheets("Sheet1").Range("M145").value
fName = Application.GetSaveAsFilename(wbName)
If fName = False Then
MsgBox "Publish couldn't be completed since you didn't choose where to save the file."
Exit Sub
Else
Set wb = Workbooks.Add
wb.SaveAs (fName)
End If
Run Code Online (Sandbox Code Playgroud)
但似乎每当单元格"M145"包含"31.3.16"中的点(".")时,我的文件名不会出现在SaveAs提示中,我看到一个空白行没有任何错误消息.
我不认为这与它有任何关系,但我的表是从右到左.有没有人知道如何解决这个问题?
虽然我无法复制错误,但也许你会对一个FileDialog对象有更好的运气:
Dim wb As Workbook
Dim wbName As String
Dim fdlg As FileDialog
wbName = ThisWorkbook.Sheets("Sheet1").Range("M145").value
Set fdlg = Application.FileDialog(msoFileDialogSaveAs)
With fdlg
.InitialFileName = wbName
.Show
Set wb = Workbooks.Add
On Error Resume Next 'Suppress any errors due to invalid filename, etc.
wb.SaveAs(fdlg.SelectedItems(1))
If Err.Number <> 0 Then
MsgBox "Publish couldn't be completed since you didn't choose where to save the file."
wb.Close False 'Get rid of the workbook since it's not being saved
Exit Sub
End If
On Error GoTo 0 'Resume normal error handling
End With
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
544 次 |
| 最近记录: |