UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Vba Routine Causes Vba To Get Lost, Office 2013    
 
   
likajoho
post Jul 30 2020, 06:27 AM
Post#1



Posts: 1,090
Joined: 18-February 04
From: Oklahoma


I ran a VBA routine to convert multiple MS Word documents to text. In the process I followed the instructions to the T, except I saved the routine so I could use it again. After it ran, the screen changed. The font increased and I can no longer access VBA at all. There is no longer an "Insert VBA..." as an option anywhere.

This was obtained from Office Extend. I have sent a comment to them, but have gotten no response.

Please help.
This post has been edited by likajoho: Jul 30 2020, 06:28 AM
Go to the top of the page
 
BruceM
post Jul 30 2020, 06:49 AM
Post#2


UtterAccess VIP
Posts: 8,157
Joined: 24-May 10
From: Downeast Maine


It will help to see the routine, and maybe to know its source.
Go to the top of the page
 
likajoho
post Jul 30 2020, 07:52 AM
Post#3



Posts: 1,090
Joined: 18-February 04
From: Oklahoma


My instructions from <https://www.extendoffice.com/documents/word/5552-convert-word-to-txt.html>:

"Batch Convert Word Documents To Txt Files With VBA
The below VBA code can help to convert all Word documents in a specific folder to txt files at once. Please do as follows.

1. In Word document, press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, click Insert > Module, then copy below code into the Module window.

VBA code: Batch convert Word documents to txt files

CODE
Sub ConvertDocumentsToTxt()
'Updated by Extendoffice 20181123
    Dim xIndex As Long
    Dim xFolder As Variant
    Dim xFileStr As String
    Dim xFilePath As String
    Dim xDlg As FileDialog
    Dim xActPath As String
    Dim xDoc As Document
    Application.ScreenUpdating = False
    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xDlg.Show <> -1 Then Exit Sub
    xFolder = xDlg.SelectedItems(1)
    xFileStr = Dir(xFolder & "\*.doc")
    xActPath = ActiveDocument.Path
    While xFileStr <> ""
        xFilePath = xFolder & "\" & xFileStr
        If xFilePath <> xActPath Then
            Set xDoc = Documents.Open(xFilePath, AddToRecentFiles:=False, Visible:=False)
            xIndex = InStrRev(xFilePath, ".")
            Debug.Print Left(xFilePath, xIndex - 1) & ".txt"
            xDoc.SaveAs Left(xFilePath, xIndex - 1) & ".txt", FileFormat:=wdFormatText, AddToRecentFiles:=False
            xDoc.Close True
        End If
        xFileStr = Dir()
    Wend
    Application.ScreenUpdating = True
End Sub


3. Press the F5 key to run the code.

4. In the Browse window, select the folder contains Word documents you will convert to txt files, and click the OK button. See screenshot:

Then you can see all documents in selected folder are converted to txt files at once. See screenshot:"

[EDITED BY:cheekybuddha to add code tags for readability]
Go to the top of the page
 
likajoho
post Jul 30 2020, 07:53 AM
Post#4



Posts: 1,090
Joined: 18-February 04
From: Oklahoma


Indents got lost in the copying.
Go to the top of the page
 
FrankRuperto
post Jul 30 2020, 08:30 AM
Post#5



Posts: 1,219
Joined: 21-September 14
From: Tampa, Florida USA


Button after the smiley in the editor encloses weblinks within tags:

https://www.extendoffice.com/documents/word...ord-to-txt.html

Far right button in the editor encloses the code within tags:

CODE
Sub ConvertDocumentsToTxt()
'Updated by Extendoffice 20181123
    Dim xIndex As Long
    Dim xFolder As Variant
    Dim xFileStr As String
    Dim xFilePath As String
    Dim xDlg As FileDialog
    Dim xActPath As String
    Dim xDoc As Document
    Application.ScreenUpdating = False
    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xDlg.Show <> -1 Then Exit Sub
    xFolder = xDlg.SelectedItems(1)
    xFileStr = Dir(xFolder & "\*.doc")
    xActPath = ActiveDocument.Path
    While xFileStr <> ""
        xFilePath = xFolder & "\" & xFileStr
        If xFilePath <> xActPath Then
            Set xDoc = Documents.Open(xFilePath, AddToRecentFiles:=False, Visible:=False)
            xIndex = InStrRev(xFilePath, ".")
            Debug.Print Left(xFilePath, xIndex - 1) & ".txt"
            xDoc.SaveAs Left(xFilePath, xIndex - 1) & ".txt", FileFormat:=wdFormatText, AddToRecentFiles:=False
            xDoc.Close True
        End If
        xFileStr = Dir()
    Wend
    Application.ScreenUpdating = True
End Sub

This post has been edited by FrankRuperto: Jul 30 2020, 08:39 AM
Attached File(s)
Attached File  editing.png ( 96.34K )Number of downloads: 9
 

--------------------
Currently supporting pawnbrokers that use my store management system developed with Access 2010 on Windows7. Experienced with Informix, Oracle & PostgreSQL db's.
Go to the top of the page
 
likajoho
post Jul 30 2020, 10:05 AM
Post#6



Posts: 1,090
Joined: 18-February 04
From: Oklahoma


OK. Thanks.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    6th August 2020 - 08:22 AM