FileFormat options?

BarefootPaul

Board Regular
Joined
Jul 21, 2011
Messages
54
I wrote this code to populate a cell in the file and then save it to a location on a shared folder on the server. When it runs it fails to save it at all.

PHP:
Private Sub BtnOK_Click()
    ActiveWorkbook.Sheets("Info").Activate
    Range("A3").Select
    If IsEmpty(TxtCredentials.Value) = True Then
        ActiveCell.Value = TxtFName.Value & " " & TxtLName.Value
    ElseIf IsEmpty(TxtCredentials.Value) = False Then
        ActiveCell.Value = TxtFName.Value & " " & TxtLName.Value & ", " & TxtCredentials.Value
    End If
 
    Dim MyName As String
    Dim MyPath As String
    MyName = TxtFName.Value & " " & TxtLName.Value & " TCM Billing Log 2011.xlsm"
    MyPath = "I:\Forms\Billing\Users\" & TxtEmail.Value & "\"
    ActiveWorkbook.SaveAs Filename = MyPath & MyName, FileFormat = xlOpenXMLWorkbookMacroEnabled
    MsgBox ("Your Billing Log has been saved to the shared drive at I:\Forms\Billing\Users\" & TxtEmail & "\ as" & TxtFName.Value & " " & TxtLName.Value & " TCM Billing Log 2011.xlsm.")
End Sub

I have read http://www.rondebruin.nl/saveas.htm and tried using FileFormat = 52, but get the same error.

Any help would be greatly appreciated. I am new to this and welcome any and all feedback.

Thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Do you need to add a path separator at the end of MyPath?

Code:
MyPath = "I:\Forms\Billing\Users\" & TxtEmail.Value & "[COLOR="Red"]\[/COLOR]"
 
Upvote 0
I have it that way in my code. I must have copied it when I was fooling around trying to get something to work. If I remove the FileFormat option from the code, it will save the workbook to the Documents directory as False.xls. Which, of course, is not what I want.
 
Upvote 0
Try this...
Code:
ActiveWorkbook.SaveAs Filename[COLOR="Red"]:=[/COLOR]MyPath & MyName, FileFormat[COLOR="Red"]:=[/COLOR]xlOpenXMLWorkbookMacroEnabled
 
Upvote 0
Thanks, that saved it as an .xlsm file, though it still saved it in my Documents folder as False.xlsm.

I guess I need to figure out why the Path and File name are not working right. That will be for tomorrow!

Why does it want := instead of =? Should I be using that in all of the code in 2010?

Thanks again.
 
Upvote 0
FileName and FileFormat are argument labels for SaveAS. They are not variables.

Arguments use the syntax; ArgLabel:=

Variables use the equal sign to set a value.
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top