{假如你要保存在本文件夹里的,photos文件夹下。
Private Sub CommandButton1_Click()
Dim name as string
Dim Potopath as string
Potopath=ThisWorkbook.Path
name = EIF.ENO.text
On Error GoTo line
Application.ActiveWorkbook.SaveAs filename:=potopath &photos&name, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
MsgBox "上传成功"
Exit Sub
line:
MsgBox "上传失败"
Exit Sub
End If
End Sub
试下可不可以。不行的话,你查下Application.ActiveWorkbook.SaveAs filename的用法,用F1查,应该对你有帮助。 }
假设:1、在你的sheet1中只有一个Shape组合,
2、在你的文件中存在sheet2这个表
参考代码如下:
'代码开始
Sub Try()
Dim iShape As Shape, iChart As ChartObject, FileName As String
Set iShape = Sheets(1).Shapes(1)
iShape.CopyPicture Appearance:=xlScreen, Format:=xlPicture'复制到剪贴板
Set iChart = Sheets(2).ChartObjects.Add(0, 0, iShape.Width, iShape.Height)
iChart.Chart.Paste
FileName = Application.GetSaveAsFilename(InitialFileName:="iPicture", _
FileFilter:="JPEG文件(*.jpg),*.jpg", _
Title:="指定文件名")
If FileName = "False" Then GoTo Exit_Line '如果点击取消按钮则退出
iChart.Chart.Export FileName:=FileName, FilterName:=UCase(Right(FileName, 3))'导出为图片文件
Exit_Line:
iChart.Delete
End Sub
'代码结束
程序运行时会要求你输入文件名,或用默认的文件名iPicture,然后会在你指定的位置生成一个jpg文件。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)