SaveAs using VB

L

Living the Dream

Hi guy's

Can anyone help me put the following into the correct syntax so it will
work using 2003 please..

Function NewName() As String
Dim strFName As String
strFName = ActiveWorkbook.FullName
GetFullFile = Replace(strFName, ".xls", "a")
End Function

The reason I am wanting to use the above is to strip away the extension
because when the below code runs it saves it like this:

TMS_2012_10_19.xlsa.xml

When in fact I need it to be:

TMS_2012_10_19a.xml

My issue is I don't know where to insert it, or at least call the
function in order to set mySwb as the newly renamed active ( NewName )
workbook.

Sub Create_XML()

Dim myExtStr As String
Dim mySwb As Workbook
Dim myFileDir As String
Dim myFilePath As String
Dim myFileName As String

Set mySwb = ActiveWorkbook

myFileName = mySwb.Name & "a"
myFilePath = "T:\myFolder\"
myExtStr = ".xml": FileFormatNum = 46


With mySwb
.SaveAs myFilePath & myFileName & myExtStr
End With

End Sub

TIA
Mick.
 
A

Auric__

Living said:
Can anyone help me put the following into the correct syntax so it will
work using 2003 please..

Function NewName() As String
Dim strFName As String
strFName = ActiveWorkbook.FullName
GetFullFile = Replace(strFName, ".xls", "a")
End Function

The reason I am wanting to use the above is to strip away the extension
because when the below code runs it saves it like this:

TMS_2012_10_19.xlsa.xml

When in fact I need it to be:

TMS_2012_10_19a.xml

My issue is I don't know where to insert it, or at least call the
function in order to set mySwb as the newly renamed active ( NewName )
workbook.

Add a dot at the end:
GetFullFile = Replace(strFName, ".xls", "a.")
 
L

Living the Dream

Hi Auric

Apologies for not replying sooner.

I managed to get a work around so it's all good

Thanks again.

Mick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top