ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Excel Help - Filename (https://www.excelbanter.com/excel-programming/324782-vba-excel-help-filename.html)

[email protected]

VBA Excel Help - Filename
 
I am trying to do the following: I am using excel and I have a
checkbox and once that box is checked I want it to see if it has been
saved if not then i want the "Save as" method to show but if the file
has already been saved then I want it to just the save the changes and
not show the "Save As" dialog every time the check box is checked


The following is the code i am working: any ideas on what i may be
doing worng???


Sub CheckBox1_Click()
Dim amessage As Outlook.MailItem
Dim test As String
Dim filename As String


If Not ActiveWorkbook.Saved Then
filesavename = Excel.Application.GetSaveAsFil*ename( _
filefilter:="Excel Files (*.xls), *.xls")
ThisWorkbook.SaveAs filename:=filesavename


End If


If ThisWorkbook.Saved = True Then
test = inputbox("Please enter an email address:")
Set outsess = CreateObject("outlook.Applicat*ion")
Set amessage = outsess.CreateItem(olMailItem)
amessage.BodyFormat = olFormatHTML
amessage.To = test
'more code but didnt display it all
End if


Vasant Nanavati

VBA Excel Help - Filename
 
If Not ActiveWorkbook.Saved Then
If ActiveWorkbook.Path = "" Then
filesavename = Excel.Application.GetSaveAsFil*ename( _
filefilter:="Excel Files (*.xls), *.xls")
ThisWorkbook.SaveAs filename:=filesavename
Else
ActiveWorkbook.Save
End If
End If

--

Vasant




All times are GMT +1. The time now is 01:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com