opening and saving files

J

jennifer

I have a macro that opens an HTML file and then saves it as a Word
doc. I'm trying to bypass to dialogs that require user input, but I
haven't figured out how.

The first one occurs when the macro opens the file, and says "some of
the files in this web page aren't in the expected location. do you
want to download them anyway" - the answer should always be "yes".
Here's the code I used to open the file:

Documents.Open FileName:="objectref.html",
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto

The second one occurs when the macro attempts to save the file from
html to doc. It reads: "some of the features in this document aren't
supported by Microsoft Internet Explorer 4.0 and Netscape Navigator
4.0". The feature its complaining about is linked style sheets. I
just want to tell this dialog to "continue". Here's the code to save
the file:

fname$ = ActiveDocument.Name
If InStr(1, fname$, ".") > 0 Then
fname$ = Left$(fname$, InStr(1, fname$, ".") - 1)
End If
myFileName$ = ActiveDocument.Name
newFileName$ = fname$ + ".doc"
ActiveDocument.SaveAs FileName:=newFileName$,
FileFormat:=wdFormatDocument

I'm using Word XP. Any help would be appreciated!
 
W

Word Heretic

G'day (e-mail address removed) (jennifer),

application.displayalerts can block some

(e-mail address removed) (jennifer) was spinning this yarn:
I have a macro that opens an HTML file and then saves it as a Word
doc. I'm trying to bypass to dialogs that require user input, but I
haven't figured out how.

The first one occurs when the macro opens the file, and says "some of
the files in this web page aren't in the expected location. do you
want to download them anyway" - the answer should always be "yes".
Here's the code I used to open the file:

Documents.Open FileName:="objectref.html",
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto

The second one occurs when the macro attempts to save the file from
html to doc. It reads: "some of the features in this document aren't
supported by Microsoft Internet Explorer 4.0 and Netscape Navigator
4.0". The feature its complaining about is linked style sheets. I
just want to tell this dialog to "continue". Here's the code to save
the file:

fname$ = ActiveDocument.Name
If InStr(1, fname$, ".") > 0 Then
fname$ = Left$(fname$, InStr(1, fname$, ".") - 1)
End If
myFileName$ = ActiveDocument.Name
newFileName$ = fname$ + ".doc"
ActiveDocument.SaveAs FileName:=newFileName$,
FileFormat:=wdFormatDocument

I'm using Word XP. Any help would be appreciated!

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email (e-mail address removed)
Products http://www.geocities.com/word_heretic/products.html

Replies offlist may require payment.
 
C

Cindy Meister -WordMVP-

Hi Jennifer,

No, I don't think so. Unless you're absolutely certain the dialog box
will be displayed, then you could probably take your chances with
putting a SendKeys just before Documents.Open that "presses" the
correct key for you.
That works, but "Application.DisplayAlerts = wdAlertsNone" will apply
the default response to the skipped dialog (in this case "no" is the
default response).

Is there any way to set the response to be "yes"?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top