1

I am trying to open a folder full of powerpoint files all with arabic (unicode) names and and edit them, then I knew about VBA and found this code here

yet when I tried to use it it doesn't open the files and always come with and error in the 'open' function

I also tried this solution here too -the StrConv function - but it doesn't seem to work either.

here is my final code

Sub BatchSave()
' Opens each PPT in the target folder and saves as PPT97-2003 format

Dim sFolder As String
Dim sPresentationName As String
Dim oPresentation As Presentation

' Get the foldername:

'sFolder = InputBox("Folder containing PPT files to process", "Folder")
sFolder = "E:\taranem\tttt\tranem"
If sFolder = "" Then
    Exit Sub
End If

' Make sure the folder name has a trailing backslash
If Right$(sFolder, 1) <> "\" Then
    sFolder = sFolder & "\"
End If

' Are there PPT files there?
If Len(Dir$(sFolder & "*.PPT")) = 0 Then
    MsgBox "Bad folder name or no PPT files in folder."
    Exit Sub
End If

' Open and save the presentations
sPresentationName = Dir$(sFolder & "*.ppt")
While sPresentationName <> ""
    f = sFolder & StrConv(sPresentationName, vbFromUnicode)
    Set oPresentation = Presentations.Open(f, , , False)
    Call oPresentation.SaveAs(sFolder & "N_" & sPresentationName, ppSaveAsShow)
    oPresentation.Close
    ' New presentation is now saved as N_originalname.ppt
    ' Now let's rename them - comment out the next couple lines
    '   if you don't want to do this
    ' Original.PPT to Original.PPT.OLD
    Name sFolder & sPresentationName As sFolder & sPresentationName & ".OLD"
    ' N_Original.PPT to Original.PPT
    Name sFolder & "N_" & sPresentationName As sFolder & sPresentationName
    sPresentationName = Dir$()
Wend

MsgBox "DONE"

End Sub

indentation is missed up I know xD

Community
  • 1
  • 1
Andrew Raafat
  • 33
  • 1
  • 1
  • 5
  • "and always come with and error in the 'open' function" What's the error message (or your best guess at a translation, in case it's not in English) – Steve Rindsberg Mar 05 '15 at 01:15
  • actually it's a plain run time error every time http://i.imgur.com/6zKPDVx.png – Andrew Raafat Mar 05 '15 at 12:21
  • Can you post an example file on DropBox or the like? The contents don't matter, so long as it has a name in Arabic like the ones you're working with. – Steve Rindsberg Mar 06 '15 at 17:45
  • sure, here is an example file https://www.dropbox.com/s/d2bkclpbo5y5s97/%D9%85%D9%84%D9%81%20%D8%A8%D8%A3%D8%B3%D9%85%20%D8%B9%D8%B1%D8%A8%D9%8A.ppt?dl=0 – Andrew Raafat Mar 07 '15 at 10:25
  • Thanks. I think the problem is that VB corrupts the file name when returning it from Dir$, so it's broken before it starts. I did a bit of googling and found this, which might help: http://www.vbforums.com/showthread.php?555086-RESOLVED-Unicode-file-names&highlight=FindNextFileW/#4...don't – Steve Rindsberg Mar 08 '15 at 02:19

0 Answers0