Hi All,

I am trying to write a fairly simple search and replace piece of code
that I will expand later to do multiple search / replaces, but I
cannot get it to work on just one even!

The code is below, and it gives a 'Permission Denied' error (70) on
the final line before the 'End Sub'.

The active document is a single HTML document, saved on my hard disk.
I can do a search / replace / save manually no problem so I don't
think it is a file permissions issue in Windows.

Any help is much appreciated - I am a newbie with FP VBA so please be
gentle!

Alan.


+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


Sub Test()

Dim objPage As DispFPHTMLDocument

Dim strFind As String
Dim strReplace As String
Dim strTest As String

Set objPage = ActiveDocument

strFind = "/abc.nsf"
strReplace = "http://www.mydomain.com/abc.nsf"

strTest = Replace(objPage.DocumentHTML, strFind, strReplace)

' This next line errors with permission denied,
' yet the HTML file is on my HDD

objPage.DocumentHTML = strTest

End Sub

Re: Simple search replace code - Permission Denied Error by Steve

Steve
Mon Mar 14 10:12:53 CST 2005

I have to ask: Why not just use the global replace feature of FrontPage, as it will do
exactly what you're trying to do if you tell it to search html??


"Alan" <alan@alan.alan> wrote in message news:OkEvkzBKFHA.2628@tk2msftngp13.phx.gbl...
>
> Hi All,
>
> I am trying to write a fairly simple search and replace piece of code
> that I will expand later to do multiple search / replaces, but I
> cannot get it to work on just one even!
>
> The code is below, and it gives a 'Permission Denied' error (70) on
> the final line before the 'End Sub'.
>
> The active document is a single HTML document, saved on my hard disk.
> I can do a search / replace / save manually no problem so I don't
> think it is a file permissions issue in Windows.
>
> Any help is much appreciated - I am a newbie with FP VBA so please be
> gentle!
>
> Alan.
>
>
> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>
>
> Sub Test()
>
> Dim objPage As DispFPHTMLDocument
>
> Dim strFind As String
> Dim strReplace As String
> Dim strTest As String
>
> Set objPage = ActiveDocument
>
> strFind = "/abc.nsf"
> strReplace = "http://www.mydomain.com/abc.nsf"
>
> strTest = Replace(objPage.DocumentHTML, strFind, strReplace)
>
> ' This next line errors with permission denied,
> ' yet the HTML file is on my HDD
>
> objPage.DocumentHTML = strTest
>
> End Sub
>
>
>
>
>
>
>
>



Re: Simple search replace code - Permission Denied Error by Jim

Jim
Mon Mar 14 12:30:49 CST 2005

Alan wrote:
> Hi All,
>
> I am trying to write a fairly simple search and replace piece of code
> that I will expand later to do multiple search / replaces, but I
> cannot get it to work on just one even!
>
> The code is below, and it gives a 'Permission Denied' error (70) on
> the final line before the 'End Sub'.
>
> The active document is a single HTML document, saved on my hard disk.
> I can do a search / replace / save manually no problem so I don't
> think it is a file permissions issue in Windows.
>

Are you in Design/Normal view when this code runs? You need to be. I would
add some code in there to switch into Design/Normal view before you set the
DocumentHTML property.

--
Jim Cheshire
JIMCO
http://www.jimcoaddins.com

Check out Spam Spoiler, our new add-in!
Add e-mail links to your Web site again
without fear of spammers!




Re: Simple search replace code - Permission Denied Error by Jim

Jim
Mon Mar 14 12:31:25 CST 2005

Steve Easton wrote:
> I have to ask: Why not just use the global replace feature of
> FrontPage, as it will do exactly what you're trying to do if you tell
> it to search html??
>
>

That's no fun! Besides what do you learn that way? ;)

--
Jim Cheshire
JIMCO
http://www.jimcoaddins.com

Check out Spam Spoiler, our new add-in!
Add e-mail links to your Web site again
without fear of spammers!




Re: Simple search replace code - Permission Denied Error by Alan

Alan
Mon Mar 14 14:48:09 CST 2005


"Jim Cheshire (JIMCO)" <contactme@mysite.com> wrote in message
news:OeRF6PMKFHA.3960@TK2MSFTNGP09.phx.gbl...
>
> Are you in Design/Normal view when this code runs? You need to be.
I would
> add some code in there to switch into Design/Normal view before you
set the
> DocumentHTML property.
>

Doh! Doh! Doh!

Thanks Jim - much appreciated.

I am much more an [WHISPER] excel vba programmer [/WHISPER].

FP is somewhat different I am finding, but I suspect that my general
understanding of VBA will improve from the broader knowledge.

Thanks again,

Alan.



Re: Simple search replace code - Permission Denied Error by Alan

Alan
Mon Mar 14 14:45:21 CST 2005

"Steve Easton" <admin@95isalive.com> wrote in message
news:%23BjJbELKFHA.1812@TK2MSFTNGP15.phx.gbl...
>
> I have to ask: Why not just use the global replace feature of
> FrontPage, as it will do exactly what you're trying to do if you
tell
> it to search html??
>

Hi Steve,

The files are not all in one web, so I (thought?) I could not use the
gloabl S&R functionality - but perhaps I can....??

Thanks,

Alan.



Re: Simple search replace code - Permission Denied Error by Steve

Steve
Mon Mar 14 17:12:18 CST 2005

You are correct in that the global replace will only work in one web at a time. Also the web "must"
be opened in FrontPage.

That said, and looking at your code example, I "think" you are going to run into permissions issues
because your code doesn't open the web via FrontPage. Therefore you will not have "write"
permissions on the files.

( Note I said: "I think" )


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer

"Alan" <alan@alan.alan> wrote in message news:%23vHcJeNKFHA.1176@TK2MSFTNGP12.phx.gbl...
> "Steve Easton" <admin@95isalive.com> wrote in message
> news:%23BjJbELKFHA.1812@TK2MSFTNGP15.phx.gbl...
> >
> > I have to ask: Why not just use the global replace feature of
> > FrontPage, as it will do exactly what you're trying to do if you
> tell
> > it to search html??
> >
>
> Hi Steve,
>
> The files are not all in one web, so I (thought?) I could not use the
> gloabl S&R functionality - but perhaps I can....??
>
> Thanks,
>
> Alan.
>
>



Re: Simple search replace code - Permission Denied Error by Alan

Alan
Mon Mar 14 17:40:28 CST 2005

"Steve Easton" <admin@95isalive.com> wrote in message
news:%23r3cRuOKFHA.3184@TK2MSFTNGP09.phx.gbl...
>
> You are correct in that the global replace will only work in one web
> at a time. Also the web "must" be opened in FrontPage.
>
> That said, and looking at your code example, I "think" you are going
> to run into permissions issues because your code doesn't open the
> web via FrontPage. Therefore you will not have "write" permissions
> on the files.
>
> ( Note I said: "I think" )
>

Noted!

I will give it a go and post back here if I get stuck again.

Thanks for your assistance,

Alan.





Re: Simple search replace code - Permission Denied Error by Jim

Jim
Mon Mar 14 19:10:36 CST 2005

Steve Easton wrote:
> You are correct in that the global replace will only work in one web
> at a time. Also the web "must" be opened in FrontPage.
>
> That said, and looking at your code example, I "think" you are going
> to run into permissions issues because your code doesn't open the web
> via FrontPage. Therefore you will not have "write" permissions on
> the files.
>
> ( Note I said: "I think" )
>
>

The code he posted is VBA code which dictates that the file is open in
FrontPage. As far as permissions are concerned, Windows permissions will be
the same whether he opens the page with FrontPage or Notepad.

The issue that Alan was having was caused by trying to programmatically
manipulate a page while in Code/HTML view. The FrontPage object model does
not allow that.

--
Jim Cheshire
JIMCO
http://www.jimcoaddins.com

Check out Spam Spoiler, our new add-in!
Add e-mail links to your Web site again
without fear of spammers!




Re: Simple search replace code - Permission Denied Error by Steve

Steve
Mon Mar 14 20:45:25 CST 2005

Ok. "I think" I understand, but...

He referenced an http://www.domainname.com url which made me "assume" the objective is to find and
replace html in a page on a remote server. Hence my question about the permissions issue.

Did I misunderstand or overlook something??



--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer

"Jim Cheshire (JIMCO)" <contactme@mysite.com> wrote in message
news:OPrZVvPKFHA.2764@tk2msftngp13.phx.gbl...
> Steve Easton wrote:
> > You are correct in that the global replace will only work in one web
> > at a time. Also the web "must" be opened in FrontPage.
> >
> > That said, and looking at your code example, I "think" you are going
> > to run into permissions issues because your code doesn't open the web
> > via FrontPage. Therefore you will not have "write" permissions on
> > the files.
> >
> > ( Note I said: "I think" )
> >
> >
>
> The code he posted is VBA code which dictates that the file is open in
> FrontPage. As far as permissions are concerned, Windows permissions will be
> the same whether he opens the page with FrontPage or Notepad.
>
> The issue that Alan was having was caused by trying to programmatically
> manipulate a page while in Code/HTML view. The FrontPage object model does
> not allow that.
>
> --
> Jim Cheshire
> JIMCO
> http://www.jimcoaddins.com
>
> Check out Spam Spoiler, our new add-in!
> Add e-mail links to your Web site again
> without fear of spammers!
>
>
>



Re: Simple search replace code - Permission Denied Error by Jim

Jim
Mon Mar 14 21:15:00 CST 2005

Steve Easton wrote:
> Ok. "I think" I understand, but...
>
> He referenced an http://www.domainname.com url which made me "assume"
> the objective is to find and replace html in a page on a remote
> server. Hence my question about the permissions issue.
>
> Did I misunderstand or overlook something??
>
>

I think so. What he is doing is replacing a link that says /abc.htm with
the absolute URL. That doesn't mean that he is necessarily saving a page to
a remote URL. It's also the case that opening a file on a FrontPage
extended site is always going to open the site itself, so if you have
permission to author the site, you can save changes. :)

--
Jim Cheshire
JIMCO
http://www.jimcoaddins.com

Check out Spam Spoiler, our new add-in!
Add e-mail links to your Web site again
without fear of spammers!




Re: Simple search replace code - Permission Denied Error by Alan

Alan
Tue Mar 15 15:30:55 CST 2005

"Jim Cheshire (JIMCO)" <contactme@mysite.com> wrote in message
news:OjhJ20QKFHA.1740@TK2MSFTNGP10.phx.gbl...

> Steve Easton wrote:
>> Ok. "I think" I understand, but...
>>
>> He referenced an http://www.domainname.com url which made me
>> "assume" the objective is to find and replace html in a page on a
>> remote server. Hence my question about the permissions issue.
>>
>> Did I misunderstand or overlook something??
>>
>
> I think so. What he is doing is replacing a link that says /abc.htm
> with the absolute URL. That doesn't mean that he is necessarily
> saving a page to a remote URL. It's also the case that opening a
> file on a FrontPage extended site is always going to open the site
> itself, so if you have permission to author the site, you can save
> changes. :)
>

Guys - your conversation is seriously over my head, but this last part
is correct - I was opening and re-saving the HTML file on my local
HDD, not on a remote server (although the original file was saved to
my HDD from a remote server).

Thank you again for all your assistance - I am learning bucketloads
here so I will probaby soon be up from 'totally ignorant' to 'mildly
dangerous' in terms of my knowledge!

Regards,

Alan.