Re: Opening files according to extension

From: Doug Robbins - Word MVP (dkr_at_NOmvpsSPAM.org)
Date: 04/13/04


Date: Tue, 13 Apr 2004 15:43:24 +1000

Insert a MsgBox currentFile and see what it returns.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested.  Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Carlos Chalhoub" <carlos.chalhoub@solcorp.com> wrote in message
news:OTBl9JJIEHA.2972@TK2MSFTNGP12.phx.gbl...
> Hi Doug,
>
> When I add this line, I get a: "Compile error in hidden module". What's
> happening?
>
> Thanks
> Carlos
>
>
> "Doug Robbins - Word MVP" <dkr@NOmvpsSPAM.org> wrote in message
> news:ONQR3TcHEHA.2876@TK2MSFTNGP09.phx.gbl...
> > Hi Carlos,
> >
> > Instead of
> >
> >     If fileNames = "*.htm" Then
> >
> > Use
> >
> >     If LCase(Right(currentFile, 3)) = "htm" Then
> >
> > --
> > Please post any further questions or followup to the newsgroups for the
> > benefit of others who may be interested.  Unsolicited questions
forwarded
> > directly to me will only be answered on a paid consulting basis.
> >
> > Hope this helps
> > Doug Robbins - Word MVP
> > "Carlos Chalhoub" <carlos.chalhoub@solcorp.com> wrote in message
> > news:uv9I1OXHEHA.3032@TK2MSFTNGP09.phx.gbl...
> > > Hi listmates,
> > >
> > > I've inherited a UserForm from 1997 that I'm trying to update for our
> use
> > > in
> > > this year. A few things have changed in the underlying macros and I've
> had
> > > to add a couple of checkboxes. Previsously all the checkboxes ran the
> same
> > > browse directory and opened Word files. However, the 2 new checkboxes
> must
> > > open HTML files in txt format. How can I make the macro capture the
> > > extension of the file and open it accordingly? I've added the main
piece
> > > of
> > > the macro. Thanks for your help.
> > >
> > > Carlos
> > >
> > >
> > > Function PerformGlobalChange(inputChoice As Integer, aKeyword As
String,
> > > aTitle As String, aSubject As String, aAuthor As String, aCompany As
> > > String)
> > >
> > >    Dim resp As Integer
> > >    Dim fileNames As String
> > >    Dim selectChoice As Integer
> > >    ' Initialize variables
> > >
> > >    fileNames = "*.<Please enter proper file extension>"
> > >
> > >    If Windows.Count <> 0 Then
> > >        MsgBox "Please close all windows and try again.", , "SOLCORP"
> > >        End
> > >    End If
> > >
> > >    resp = MsgBox("Do you want to make global changes to the
> documentation
> > > files?", vbAbortRetryIgnore + vbYesNo, "SOLCORP")
> > >    If resp = vbNo Then End
> > >
> > >    fileNames = InputBox("Enter the names of the files you want to
> > > process.", "SOLCORP", fileNames)
> > >    If fileNames = "" Then End
> > >
> > >    MsgBox "In the next window, change to the directory where the files
> > > are,
> > > and then click Open.", _
> > >    vbDefaultButton1, "SOLCORP"
> > >
> > >    Call ListDirectoryAndFiles(fileNames)
> > >
> > > ********* This is where I want it to decide how to open the
> files*********
> > >    For i = 1 To fs.FoundFiles.Count
> > >        currentFile = fs.FoundFiles.Item(i)
> > >        If fileNames = "*.htm" Then
> > >        Documents.Open Format = wdOpenFormatText
> > >        Else: Documents.Open fileName:=currentFile
> > >        End If
> > > '***********************************************************
> > >
> > >        ' Perform global changes
> > >        choice = inputChoice
> > >        If choice \ 512 = 1 Then
> > >            choice = choice Mod 512
> > >            Call mdFixHTMLCode
> > >        End If
> > >        If choice \ 256 = 1 Then
> > >            choice = choice Mod 256
> > >            Call mdOpenLinksinNewWindow
> > >        End If
> > >        If choice \ 128 = 1 Then
> > >            choice = choice Mod 128
> > >            Call ChangeCompany(aCompany)
> > >        End If
> > >        If choice \ 64 = 1 Then
> > >            choice = choice Mod 64
> > >            Call ChangeAuthor(aAuthor)
> > >        End If
> > >        If choice \ 32 = 1 Then
> > >            choice = choice Mod 32
> > >            Call ChangeSubject(aSubject)
> > >        End If
> > >        If choice \ 16 = 1 Then
> > >            choice = choice Mod 16
> > >            Call ChangeTitle(aTitle)
> > >        End If
> > >        If choice \ 8 = 1 Then
> > >            choice = choice Mod 8
> > >            Call AcceptRevision
> > >        End If
> > >        If choice \ 4 = 1 Then
> > >            choice = choice Mod 4
> > >            Call ChangeKeywords(aKeyword)
> > >        End If
> > >        If choice \ 2 = 1 Then
> > >            choice = choice Mod 2
> > >            Call RemoveTags("pcr^#^#")
> > >        End If
> > >        If choice Mod 2 = 1 Then
> > >            Call RemoveTags("fs^#^#")
> > >        End If
> > >
> > >        ActiveDocument.Close Savechanges:=wdSaveChanges
> > >    Next i
> > >
> > >    MsgBox "Macro completed.", vbDefaultButton1, "SOLCORP"
> > >
> > > End Function
> > >
> > >
> > >
> > >
> >
>
>