文件目的地问题 [英] File destination issue

查看:97
本文介绍了文件目的地问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试以第一种格式保存文件是csv和第二种格式xlsx

Try to save the file in first format is in csv and second format xlsx

保存excel文件时它自动包含CSV的目的地


即Alley_sen.csv - (第一个csv文件)  ---     OK

即... Alley_sen.csv.xlsx(第二个xlsx文件)  - 错 - 应该是Alley_sen.xlsx



因此我想在excel文件中输入.csv。请仔细研究并建议...
$


mymonth =月(日期)

myyear =年(日期)

Dim myname1 As String



myname1 = Sheets("Ins")。范围("E6")。值



每个shtNew在ActiveWorkbook.Worksheets

如果shtNew.Name<> myShtName和shtNew.Name<> myins然后



shtNew.Move

Application.DisplayAlerts = False



ActiveWorkbook.SaveAs" C:\ Output \" &安培; ActiveSheet.Name& _

"_" &安培; " ICAN" &安培; " _" &安培; myname1& " .csv",FileFormat:= xlCSV





ActiveWorkbook.SaveAs" C:\ Onutut \" &安培; ActiveWorkbook.Name& " .XLSX" ;,的FileFormat:= xlOpenXMLWorkbook,CreateBackup:=假



ActiveWorkbook.Close

while saving the excel file it was automatically includes the destination of CSV also

i.e. Alley_sen.csv -- (first csv file)  ---     OK
i.e  Alley_sen.csv.xlsx (second xlsx file)  -- Wrong -- It should be Alley_sen.xlsx

therefore i wanted to ingore .csv in excel file. please look into this and suggest...

mymonth = Month(Date)
myyear = Year(Date)
Dim myname1 As String

myname1 = Sheets("Ins").Range("E6").Value

For Each shtNew In ActiveWorkbook.Worksheets
If shtNew.Name <> myShtName And shtNew.Name <> myins Then

shtNew.Move
Application.DisplayAlerts = False

ActiveWorkbook.SaveAs "C:\Output\" & ActiveSheet.Name & _
"_" & "ICAN" & "_" & myname1 & ".csv", FileFormat:=xlCSV


ActiveWorkbook.SaveAs "C:\Output\" & ActiveWorkbook.Name & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

ActiveWorkbook.Close

推荐答案

一个简单的黑客怎么样,

How about a simple hack like,

Dim myname1 As String, fileSaveName As String

myname1 = Sheets("Ins").Range("E6").Value

For Each shtNew In ActiveWorkbook.Worksheets
	If shtNew.Name <> myShtName And shtNew.Name <> myins Then
		shtNew.Move
		Application.DisplayAlerts = False
		
		fileSaveName = "C:\Output\" & ActiveSheet.Name & "_" & "ICAN" & "_" & myname1 & ".csv"
		
		ActiveWorkbook.SaveAs fileSaveName, FileFormat:=xlCSV
		ActiveWorkbook.SaveAs Replace(fileSaveName, ".csv", ".xlsx"), FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
		ActiveWorkbook.Close


这篇关于文件目的地问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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