Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

Save doc as Webpage but cannot view in browser at the same time

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michelle - 28 Jan 2005 03:44 GMT
I am writing the following code, it will popup a save as dialog, when I got the path and name info, i run ActiveDocument.SaveAs to save doc as webpage. After that, I tried to call ActiveDocument.FollowHyperlink to open that webpage, however, nothing happen.

But then, i tried to call ActiveDocument.FollowHyperlink to open a file which is saved before, it works fine.

I feel strange that if i just saved the file, i can't immediately call ActiveDocument.FollowHyperlink to view the page. Anyone can help?

Dim Path, Name, fullPath As String

With Dialogs(wdDialogFileSaveAs)
   If .Display Then
       Path = WordBasic.FileNameInfo(.Name, 5)
       Name = WordBasic.FileNameInfo(.Name, 4)
       fullPath = Path & Name & ".html"
       ActiveDocument.SaveAs FileName:=fullPath , FileFormat:=wdFormatHTML, _
           LockComments:=False, Password:="", AddToRecentFiles:=False, WritePassword _
           :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
           SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
           False
   ActiveDocument.FollowHyperlink fullPath
   End If
End With
Klaus Linke - 28 Jan 2005 13:44 GMT
Hi Michelle,

It seems you try to open a document that already is open. So nothing happens.

If you want to see a web preview of the current doc, you could use
ActiveDocument.WebPagePreview

Regards,
Klaus

> I am writing the following code, it will popup a save as dialog, when
> I got the path and name info, i run ActiveDocument.SaveAs to save
[quoted text clipped - 25 lines]
> --
> Message posted via http://www.officekb.com
Michelle - 31 Jan 2005 06:27 GMT
But I want to open a new Browser to view the page, so I don't use
WebPagePreview.
Klaus Linke - 31 Jan 2005 17:28 GMT
> But I want to open a new Browser to view the page, so I don't
> use WebPagePreview.
>
> --
> Message posted via http://www.officekb.com

Hi Michelle,

The more I look at it, the less I understand why your code doesn't work...

Maybe you can use the Shell function with iexplore.exe instead of
FollowHyperlink.

It seems messy since you have to figure out the full path to the IE program
(... if I didn't miss something obvious).
And the method doesn't work with other browsers  :-(

See code below...
Klaus

Dim strProgramFilesDir As String
strProgramFilesDir = System.PrivateProfileString("", _
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", _
"ProgramFilesDir")
Dim strIE As String
strIE = System.PrivateProfileString("", _
"HKEY_LOCAL_MACHINE\Software\Microsoft\IE Setup\Setup", _
"Path") & _
"\iexplore.exe"
strIE = Replace(strIE, "%ProgramFiles%", strProgramFilesDir, , , vbTextCompare)
Dim strShell As String
strShell = strIE

Dim Path, Name, fullPath As String
Dim fullPath2 As String
With Dialogs(wdDialogFileSaveAs)
   If .Display Then
       Path = WordBasic.FileNameInfo(.Name, 5)
       Name = WordBasic.FileNameInfo(.Name, 4)
       fullPath = Path & Name & ".html"
       ActiveDocument.SaveAs FileName:=fullPath, FileFormat:=wdFormatHTML, _
           LockComments:=False, Password:="", AddToRecentFiles:=False,
WritePassword _
           :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
           SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
           False
'    ActiveDocument.FollowHyperlink fullPath
   strShell = strShell & " " & Chr(34) & fullPath & Chr(34)
   Shell strShell, vbNormalFocus
   End If
End With

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.