Hi All:
I am confused. I was working with the partial code below yesterday. I made alterations to it (THANKS Alan) and I thought it was working properly but now soemthing has gone wrong??? It no longer functions as it should and I have no idea what I need to do to get it working again. Here is the little piece of code that is supose to save a Worksheet as a NEW Workbook giving it a preset name with the option to edit that filename. It is also supose to go to the directory specified.
Here is what I can't figure out:
A)
No matter what I set the Path to it is bringing up the intial path as:
C:|Documents and Settings\HUGGINM\Desktop in the example above it should be going to C:\New??? How can I get the correct Path to come up?
B)
The name of the file that is being created should be (in this case)
18 Jun 2007 MOHLTCK REV.xls For some reason it is being saved as ..xls (extra decimal?) eg. 18 Jun 2007..xls??? How can I get rid of the EXTRA . ???
ANY assistance would be GREATLY appreciated. I have played around since the morning but my lack of VBA skills has reulted in me accomplishing nothing?
THANKS,
Mark
I am confused. I was working with the partial code below yesterday. I made alterations to it (THANKS Alan) and I thought it was working properly but now soemthing has gone wrong??? It no longer functions as it should and I have no idea what I need to do to get it working again. Here is the little piece of code that is supose to save a Worksheet as a NEW Workbook giving it a preset name with the option to edit that filename. It is also supose to go to the directory specified.
Code:
'Save the new workbook AND Mail it
FilePath = "C:\New\"
TempFileName = Format(ActiveSheet.Range("C1"), "yyyy mm dd") & " " & "MOHLTCK REV"
NewName = Application.GetSaveAsFilename(InitialFileName:=TempFileName)
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With Destwb
.SaveAs NewName & FileExtStr, FileFormat:=FileFormatNum
On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "MOHLTC Revenue Listing Attached"
.Body = "Hi: Please see attached MOHLTC Revenue Listing for Upload to your system."
.Attachments.Add Destwb.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Display 'can use .Send or .Display
End With
On Error GoTo 0
.Close savechanges:=False
End With
'IF you want to Delete the file you have sent then Activate the line below
'Kill FilePath & FileName & FileExtStr
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Here is what I can't figure out:
A)
No matter what I set the Path to it is bringing up the intial path as:
C:|Documents and Settings\HUGGINM\Desktop in the example above it should be going to C:\New??? How can I get the correct Path to come up?
B)
The name of the file that is being created should be (in this case)
18 Jun 2007 MOHLTCK REV.xls For some reason it is being saved as ..xls (extra decimal?) eg. 18 Jun 2007..xls??? How can I get rid of the EXTRA . ???
ANY assistance would be GREATLY appreciated. I have played around since the morning but my lack of VBA skills has reulted in me accomplishing nothing?
THANKS,
Mark