Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Outlook for Mac > Macro to save a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 821 of 833
Post > Topic >>

Macro to save an xml (Excel2007) file into an Excel97 format

by =?Utf-8?B?RmlsaXAgRGUgRGVja2Vy?= <Filip De Decker@[EMAIL PROTECTED] Apr 28, 2008 at 06:47 AM

Hi, I created this macro (below) in order to let it run automatically over 
number of .xml files that have to be saved into another place(directory)
but 
as Excel97 files.
(in fact I have a DOS script that selects all .xml files in a certain 
directory. Each selected file should be opened automatically and saved 
automatically into a subdirectory called xls, saving the file as an
Excel97 
document (as you see below, I use the parameter FileFormat:=xlExcel8 _ to 
instruct VB to do so) ).
I you save the code into a file called PERSONAL.xls and put it into the 
directory ../XLSTART , excel will execute the macro right away when
started.

MY PROBLEM : this macro worked with Excel2003 but soon we are going to 
upgrade to Excel2007! The macro stops when it tries to save the file
(right 
after the MessageBox) and Excel crashes.

All help = welcome.
THnks.
Filip.

---


Option Explicit
 
 'The following function returns the filename without the extension from
the 
file's full path:
Function FileNameNoExt(strPath As String) As String
    Dim strTemp As String
    strTemp = Mid$(strPath, InStrRev(strPath, "\") + 1)
    FileNameNoExt = Left$(strTemp, InStrRev(strTemp, ".") - 1)
End Function
 
'the following function will get the path only (i.e. the folder) from the 
file's ful path:
Function FilePath(strPath As String) As String
    FilePath = Left$(strPath, InStrRev(strPath, "\"))
End Function

Sub auto_open()
       Application.Quit
End Sub

Sub auto_close()

   Dim NewFName As String
   Dim FullPathAs String

   NewFName = "xls\" & FileNameNoExt(ActiveWorkbook.FullName)
   FullPath= FilePath(ActiveWorkbook.FullName)

   MsgBox " NewFName: " & NewFName
   MsgBox " VolledigPad: " & VolledigPad

    ActiveWorkbook.SaveAs Filename:=FullPath+ "xls\" + NewFName, 
FileFormat:=xlExcel8 _
        , Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
        CreateBackup:=False
End Sub
 




 1 Posts in Topic:
Macro to save an xml (Excel2007) file into an Excel97 format
=?Utf-8?B?RmlsaXAgRGUgRGV  2008-04-28 06:47:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Jul 6 23:23:53 CDT 2008.