Re: Insert several html files into word by JGM
JGM
Mon Dec 15 12:02:45 CST 2003
Hi LMC,
Just append the code at the end of your code,
and,
change
Set fsoFldr = FSO.GetFolder("C:\HTML_FILES")
to
Set fsoFldr = FSO.GetFolder(GetPath)
Cheers!
--
_______________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca
"LMC" <lmc@lmc.com> a écrit dans le message de news:
OJFqDOxwDHA.4060@TK2MSFTNGP11.phx.gbl...
> Hi,
>
>
>
> Thanks for your answer.
>
>
>
> Can you tell me how do I insert this code into the script and how do I put
> the "GetPath = oFolder.Self.Path" into the "Set fsoFldr =
> FSO.GetFolder("C:\HTML_FILES")"?
>
>
>
> Thanks again
>
>
>
> Regards
>
>
>
> LMC
>
>
>
>
>
> "JGM" <no-spam@leaveme.alone> a écrit dans le message de
> news:uc6$%23kMwDHA.2408@tk2msftngp13.phx.gbl...
> > Hi there LMC,
> >
> > Try this:
> > '_______________________________________
> > Function GetPath() As String
> > 'Needs a reference to (Tools > Reference)
> > 'Microsoft Shell Controls And Automation
> >
> > Dim oShell As Shell32.Shell
> > Dim oFolder As Shell32.Folder
> > Dim EverythingOK As Boolean
> >
> > EverythingOK = False
> >
> > Set oShell = New Shell32.Shell
> > Set oFolder = oShell.BrowseForFolder(0, "Select ", 0)
> >
> > On Error GoTo NoPath
> > GetPath = oFolder.Self.Path
> > EverythingOK = True
> >
> > NoPath:
> > Set oFolder = Nothing
> > Set oShell = Nothing
> >
> > On Error GoTo 0
> > If EverythingOK Then Exit Function
> >
> > MsgBox "Action cancelled by user.", vbExclamation,
"Cancelled"
> > End Function
> > '_______________________________________
> >
> > HTH
> > Cheers!
> >
> > --
> > _______________________________________
> > Jean-Guy Marcil
> > jmarcil@sympatico.ca
> >
> > "LMC" <lmc@lmc.com> a écrit dans le message de news:
> > uFhvYpLwDHA.2260@TK2MSFTNGP09.phx.gbl...
> > > Have the solution:
> > >
> > > Dim FSO As FileSystemObject
> > > Dim fsoFldr As Folder
> > > Dim fsoFile As File
> > > Dim i As Long
> > > Set FSO = New FileSystemObject
> > > Set fsoFldr = FSO.GetFolder("C:\HTML_FILES")
> > > For Each fsoFile In fsoFldr.Files
> > > With ActiveDocument.Range
> > > .InsertAfter fsoFile.Path
> > > .Collapse 0
> > > .InsertFile FileName:=fsoFile.Path, Range:="", ConfirmConversions _
> > > :=False, Link:=False, Attachment:=False
> > > .Collapse 0
> > > End With
> > > DoEvents
> > > Next
> > > Set fsoFile = Nothing
> > > Set fsoFldr = Nothing
> > > Set FSO = Nothing
> > > -------
> > > or a file format
> > > -----
> > >
> > > For Each fsoFile In fsoFldr.Files
> > > 'returns a 0 (false) if not found
> > > If InStr(fsoFile.Name,".html") Then
> > > With ActiveDocument.Range
> > > .InsertAfter fsoFile.Path
> > > .Collapse 0
> > > .InsertFile FileName:=fsoFile.Path, Range:="", ConfirmConversions _
> > > :=False, Link:=False, Attachment:=False
> > > .Collapse 0
> > > End With
> > > DoEvents
> > > End If
> > > Next
> > > -------------
> > >
> > > You'll need to add a reference to the Scripting Runtime library in the
> > > Tools -> References -> Microsoft Scripting Runtime
> > >
> > > Thanks to Wamphyri from www.visualbasicforum.com
> > > The question now is, how do I get and put information from user for
the
> > > directory name ...???
> > > Thanks
> > >
> > > LMC
> > >
> > >
> > > "LMC" <lmc@lmc.com> a écrit dans le message de
> > > news:%23X80kQJwDHA.2352@TK2MSFTNGP09.phx.gbl...
> > > > Hi,
> > > > Is there somebody who would have an answer to this problem?
> > > > I would like to insert automatically in a Word document several HTML
> > > files.
> > > > These files are in a network directory.
> > > > If I do this manually, I go to "Insert" then "Files", then look for
> HTML
> > > > files and finally Ok, then start again for a new one and so on ...
> > > > The code could be something like this (but I would like to take all
> the
> > > > *.htm files .):
> > > >
> > > > Sub InsertHtml()
> > > >
> > > > '
> > > >
> > > > Selection.InsertFile
FileName:="\\SERVER\Directory\Dir1\info.htm",
> > > > Range:="", _
> > > >
> > > > ConfirmConversions:=False, Link:=False, Attachment:=False
> > > >
> > > > End Sub
> > > >
> > > > The user should also give the directory target where all the HTML
> files
> > > are.
> > > > Any help ?
> > > >
> > > > Thanks in advance.
> > > >
> > > > LMC
> > > >
> > > >
> > >
> > >
> >
> >
>
>