Log in

View Full Version : Saving doc to docx macro problem



asset
04-08-2013, 05:07 AM
Hello,
I have a macro which is specific to the project. It converts a text into three columns, deletes second and third column, then it should save file with 'docx' extension. Here lies a problem, docx is saved in another directory. I need this macro to save 'docx' version in the same directory.
Could someone help me with this part? Thanks!
Here is the current macro:


Sub Preparefortranslation()
'
'
'
'

Selection.WholeStory

WordBasic.TextToTable ConvertFrom:=1, NumColumns:=3, NumRows:=200, _
InitialColWidth:=wdAutoPosition, Format:=0, Apply:=1184, AutoFit:=0, _
SetDefault:=0, Word8:=0, Style:="Table Grid"

ActiveDocument.Tables(1).Columns(2).Select

Selection.Columns.Delete

ActiveDocument.Tables(1).Columns(2).Select

Selection.Columns.Delete

ActiveDocument.Tables(1).Columns(1).Select

Selection.Rows.ConvertToText Separator:=wdSeparateByTabs, NestedTables:= _
True

'here I have a problem with saving file in its current directory, because file get saved in another directory((

FileName = CreateObject("scripting.filesystemobject").getbasename(ActiveDocument.Name)
ActiveDocument.SaveAs FileName:=FileName, FileFormat:=wdFormatDocumentDefault


End Sub

fumei
04-08-2013, 01:21 PM
This looks like you are saving it with the SAME name.

BTW, you can get the path(only) of the active document with:

ActiveDocument.Path & "\"

The full name with:

ActiveDocument.FullName

and just the name with:

ActiveDocument.Name

asset
04-08-2013, 08:33 PM
Hi Fumei, thanks! This works now))
Yes, I just open a doc or rtf file, but translation software understands only docx format. That's why I've created this macro, so that file is saved with the same name, but with different extension.