Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 08-28-2015, 08:14 PM
Guessed's Avatar
Guessed Guessed is offline Word macro question Windows 7 32bit Word macro question Office 2010 32bit
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I assume the Dialogs line was meant to prompt for a folder where the RTFs were going to be found. This is not happening with your code so I've changed that part.

The error you were encountering was due to the fact that you were trying to overwrite the currently open document. This code below saves it with a changed suffix so the error is avoided.
Code:
Sub RTFtoDOC()
  Dim FName As String, fldr As FileDialog, sItem As String
  Dim sNewName As String
  Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
  With fldr
    .Title = "Select a Folder"
    .AllowMultiSelect = False
    .InitialFileName = strPath
    .Show
    sItem = .SelectedItems(1) & Application.PathSeparator
  End With

  FName = Dir(sItem & "*.rtf")
  While (FName > "")
    Application.Documents.Open FileName:=sItem & FName, ReadOnly:=True, AddToRecentFiles:=False
    sNewName = Split(FName, ".")(0)
    ActiveDocument.SaveAs FileName:=sItem & sNewName, FileFormat:=wdFormatDocument
    ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
    FName = Dir()
  Wend
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word macro question Macro Question: Need help making a macro to highlight the first word in every sentence LadyAna Word 1 12-06-2014 10:39 PM
Word macro question Question about macro in word 2013 tombags Word 1 06-25-2014 04:56 PM
Word macro question Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question rsrasc Word VBA 7 03-28-2014 12:28 PM
Word macro question A newbie question: a must to save macro word file as .docm? tinfanide Word VBA 6 12-06-2011 03:02 PM
Word macro question Macro question PaulY Word VBA 1 12-22-2010 11:21 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:48 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft