J
Jan Scherpbier
I an trying to change the fileformat of an Excel sheet by means of running a macro in MS Word 2007.
I can only change the name of the excelsheet, but not the fileformat.
When is use Xlbook.saveas(naam) it works
When I use xlbook.saveas(filename = naam) the sheet is saved with then name "FALSE.xls"
When i use xlbook.saveas(filename := naam) I get "error Expect: ="
When I use xlbook.saveas(naam,56) I get "error Expect: ="
So it looks like I can only save the sheet with another name, but not with another fileformat
The code I am using is as follows:
Sub OpslaanAls()
Dim xlApp As Excel.Application, xlBook As Excel.Workbook
Set xlApp = Excel.Application
Set xlBook = xlApp.Workbooks.Open _
("\\hpa0006s\scherpbierje$\Homedir\Excel\Ulco klos\werknemers-2012-04-10(1).xls")
xlApp.Visible = True
formaat = xlBook.FileFormat
If formaat = 39 Then
naam = "\\hpa0006s\scherpbierje$\Homedir\Excel\Ulco klos\werknemersbestand.xls"
xlBook.SaveAs (naam)
'xlBook.SaveAs (FileName = naam)
'xlbook.SaveAs (naam,56)
'xlBook.SaveAs (filename = naam,fileformat = 56)
End If
xlBook.Close
'xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
I can only change the name of the excelsheet, but not the fileformat.
When is use Xlbook.saveas(naam) it works
When I use xlbook.saveas(filename = naam) the sheet is saved with then name "FALSE.xls"
When i use xlbook.saveas(filename := naam) I get "error Expect: ="
When I use xlbook.saveas(naam,56) I get "error Expect: ="
So it looks like I can only save the sheet with another name, but not with another fileformat
The code I am using is as follows:
Sub OpslaanAls()
Dim xlApp As Excel.Application, xlBook As Excel.Workbook
Set xlApp = Excel.Application
Set xlBook = xlApp.Workbooks.Open _
("\\hpa0006s\scherpbierje$\Homedir\Excel\Ulco klos\werknemers-2012-04-10(1).xls")
xlApp.Visible = True
formaat = xlBook.FileFormat
If formaat = 39 Then
naam = "\\hpa0006s\scherpbierje$\Homedir\Excel\Ulco klos\werknemersbestand.xls"
xlBook.SaveAs (naam)
'xlBook.SaveAs (FileName = naam)
'xlbook.SaveAs (naam,56)
'xlBook.SaveAs (filename = naam,fileformat = 56)
End If
xlBook.Close
'xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
End Sub