Save As wk4

A

Aaron

Hi,

A gentleman helped me yesterday and showed me how to do a save as with this
code:
'===================================
Sub SaveWithDate()
'
Dim wb As Workbook
Dim ws As Worksheet
Dim varVal As Variant
Dim strFileName As String

Set wb = ActiveWorkbook
Set ws = wb.Worksheets("$ Reference")
varVal = ws.Range("C2").Value

If IsDate(varVal) Then
strFileName = "Glue Sched_" & Format(CStr(varVal), "mm-dd-yyyy") &
".xls"
Else
strFileName = "Glue Sched_" & Format(CStr(Date), "mm-dd-yyyy") &
".xls"
End If
ChDir "\\Lan1\Supervisor\Departments\Foam\SCHEDULING\Old Schedules"
ActiveWorkbook.SaveAs Filename:=strFileName


Set wb = Nothing
Set ws = Nothing

End Sub
'======================

I now need to be able to save this file as a wk4 because this person needs
it that way. I thought I could just change the extension to wk4 above. I
did that and it saved it that way, but he was unable to open the file. I
have found that I need to choose the file type of wk4 rather than give it
that extension. Can someone help with code to change the file type to wk4 as
you would do in the drop down of the save as??
 
J

Jim Rech

How about recording a macro as you save a file in Lotus format, to get the
syntax?

--
Jim
| Hi,
|
| A gentleman helped me yesterday and showed me how to do a save as with
this
| code:
| '===================================
| Sub SaveWithDate()
| '
| Dim wb As Workbook
| Dim ws As Worksheet
| Dim varVal As Variant
| Dim strFileName As String
|
| Set wb = ActiveWorkbook
| Set ws = wb.Worksheets("$ Reference")
| varVal = ws.Range("C2").Value
|
| If IsDate(varVal) Then
| strFileName = "Glue Sched_" & Format(CStr(varVal), "mm-dd-yyyy") &
| ".xls"
| Else
| strFileName = "Glue Sched_" & Format(CStr(Date), "mm-dd-yyyy") &
| ".xls"
| End If
| ChDir "\\Lan1\Supervisor\Departments\Foam\SCHEDULING\Old Schedules"
| ActiveWorkbook.SaveAs Filename:=strFileName
|
|
| Set wb = Nothing
| Set ws = Nothing
|
| End Sub
| '======================
|
| I now need to be able to save this file as a wk4 because this person needs
| it that way. I thought I could just change the extension to wk4 above. I
| did that and it saved it that way, but he was unable to open the file. I
| have found that I need to choose the file type of wk4 rather than give it
| that extension. Can someone help with code to change the file type to wk4
as
| you would do in the drop down of the save as??
 
A

Aaron

Hi, I did try that, but did not know how to incorporate it in the given code.
I think I was missing some syntax??
 
K

Kim Greenlee

Aaron,

ActiveWorkbook.SaveAs Filename:=strFileName FileFormat:=xlWK4

This information is available in the online documentation. Follow this
link:
http://msdn.microsoft.com/library/d...-us/odc_2003_ta/html/odc_landoffice03_vba.asp
which takes you to the top of the docs, select "Microsoft Excel Visual
Basic", then "Reference", then "Methods", then "S", then "SaveAs".

Once you're on the SaveAs page select the link "SaveAs method as it applies
to the Workbook object". You can now see all the SaveAs options. By
following the FileFormat link to the FileFormat Property page, you can then
follow the link to the XlFileFormat page which lists the available FileFormat
enumerations.

Kim
 
D

Dave Peterson

You can specify the fileformat on this line:

Hi,

A gentleman helped me yesterday and showed me how to do a save as with this
code:
'===================================
Sub SaveWithDate()
'
Dim wb As Workbook
Dim ws As Worksheet
Dim varVal As Variant
Dim strFileName As String

Set wb = ActiveWorkbook
Set ws = wb.Worksheets("$ Reference")
varVal = ws.Range("C2").Value

If IsDate(varVal) Then
strFileName = "Glue Sched_" & Format(CStr(varVal), "mm-dd-yyyy") &
".xls"
Else
strFileName = "Glue Sched_" & Format(CStr(Date), "mm-dd-yyyy") &
".xls"
End If
ChDir "\\Lan1\Supervisor\Departments\Foam\SCHEDULING\Old Schedules"
ActiveWorkbook.SaveAs Filename:=strFileName


Set wb = Nothing
Set ws = Nothing

End Sub
'======================

I now need to be able to save this file as a wk4 because this person needs
it that way. I thought I could just change the extension to wk4 above. I
did that and it saved it that way, but he was unable to open the file. I
have found that I need to choose the file type of wk4 rather than give it
that extension. Can someone help with code to change the file type to wk4 as
you would do in the drop down of the save as??
 
D

Dave Peterson

Doh...

You can specify a file format on this line:

ActiveWorkbook.SaveAs Filename:=strFileName

Either look at VBA's help or record a macro when you save a test workbook as
..wk4.
 

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

Similar Threads


Top