M
MBParker
$ for a FrontPage macro to insert a particular file into the current
document. How do I do it?
In MS Word it's easy: from the Macro Recorder, it's just:
Selection.InsertFile FileName:="Section.htm", Range:="",
ConfirmConversions:=False, Link:=False, Attachment:=False
But, annoyingly, FrontPage doesn't seem to have an InsertFile method
for it's menu Insert->File menu option. To invoke the menu option
under program control, I got as a far as CommandBars("Menu
Bar").Controls("&Insert").Controls("&File...").Execute but that just
brings up the insert menu, not picking the particular file. Some
VBA'er probably knows how to finish this and plug in the file name.
More elegantly, I also tried:
Dim s as String
ActiveWeb.RootFolder.Files("FileToInclude.htm").Open
** Set s = ActiveDocument.toString ' fails because toString not
supported
** Set s = ActiveDocument.body.innerHTML ' fails due to compile
error "Object Required"
ActivePageWindow.Close False
ActiveDocument.Selection.createRange.pasteHTML (s)
but the lines marked with ** fail with the problem noted.
The only way I got it to work (quite easily) was an ActiveWords macro:
"<Alt></Alt>IFFileToInclude.htm<ENTER>". But I'd like not to have to
depend on having an external program, plus would later want to replace
some of the text I insert (as "date" for the current date) which seems
cleaner under the native macros.
Got a working solution? Be the first to post it along with your
obfuscated email and I'll send you a few bucks. -Mike Parker
â–º Now Designing www.CommuniDB.com ―“Your CommunityDatabaseâ€â„¢ (Web
2.0)
â–º Seeking interested Microsoft administrators & programmers to
volunteer in developing CommuniDB!
document. How do I do it?
In MS Word it's easy: from the Macro Recorder, it's just:
Selection.InsertFile FileName:="Section.htm", Range:="",
ConfirmConversions:=False, Link:=False, Attachment:=False
But, annoyingly, FrontPage doesn't seem to have an InsertFile method
for it's menu Insert->File menu option. To invoke the menu option
under program control, I got as a far as CommandBars("Menu
Bar").Controls("&Insert").Controls("&File...").Execute but that just
brings up the insert menu, not picking the particular file. Some
VBA'er probably knows how to finish this and plug in the file name.
More elegantly, I also tried:
Dim s as String
ActiveWeb.RootFolder.Files("FileToInclude.htm").Open
** Set s = ActiveDocument.toString ' fails because toString not
supported
** Set s = ActiveDocument.body.innerHTML ' fails due to compile
error "Object Required"
ActivePageWindow.Close False
ActiveDocument.Selection.createRange.pasteHTML (s)
but the lines marked with ** fail with the problem noted.
The only way I got it to work (quite easily) was an ActiveWords macro:
"<Alt></Alt>IFFileToInclude.htm<ENTER>". But I'd like not to have to
depend on having an external program, plus would later want to replace
some of the text I insert (as "date" for the current date) which seems
cleaner under the native macros.
Got a working solution? Be the first to post it along with your
obfuscated email and I'll send you a few bucks. -Mike Parker
â–º Now Designing www.CommuniDB.com ―“Your CommunityDatabaseâ€â„¢ (Web
2.0)
â–º Seeking interested Microsoft administrators & programmers to
volunteer in developing CommuniDB!