Hi everyone,
I have been putting together a macro that opens a word document --> saves only data for forms as text file. I have two issues that I can't seem to understand:
1) The following code works fine when I select all word docs in a folder using the msoFileDialogFolderPicker but not when I choose only one file using GetOpenFilename.
WdApp.WdBasic.DisableAutoMacros 1
WdApp.Documents.Open WdName
The error states that the Word document is protected, but this is the case in both cases above. Its the same file so why it is giving me an error only when I use the GetOpenFilename method and is there a way to circumvent this issue.
2) I want to delete all the created text files that were generated during the process but my maco won't work.
Sub KillTxtFiles()
Dim TxtName As String
Dim sFPath As String
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then sFPath = .SelectedItems(1) & "\"
End With
' Can't get the macro to delte the text files in a given folder
TxtName = Dir$(sFPath & "*.txt")
Do Until TxtName = ""
Kill (TxtName)
TxtName = Dir()
Loop
End Sub
Does anyone see what is wrong with it
Thanks in advance.
abousetta
Bookmarks