473,396 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Word Document in a WebBrowser control

Hi everybody,

I have a Word document in a WebBrowser. I modify the doc and save it with another name in another path. Finally I close my form and put my doc as nothing. My problem is that a dialog box appears sugesting me saving the changes (the changes done in the initial path) but i have already saved my document so I always want to select "No", how can I avoid this dialog box? Or if it isn't possible, how can I automatize this action?

(The dialog box appears by defect)

Thanks a lot and sorry for my english, it isn't my mother tongue.
Sep 17 '09 #1
7 15650
Frinavale
9,735 Expert Mod 8TB
A Word document in a WebBrowser?

Where is the word document supposed to save to??
Sep 17 '09 #2
I've the word document (only read) saved in MyDocuments and show it in a WebBrowser control. After modify it I save it as another one in another path...

Do u need more information?

Thanks!
Sep 17 '09 #3
kadghar
1,295 Expert 1GB
ok,

since you are using vb.net, you can, of course open a word document, using activeX:

Expand|Select|Wrap|Line Numbers
  1. dim Obj1 as object
  2. Obj1 = createobject("word.application")
  3. obj1.open("yourfile.doc")
  4. obj1.activedocument.saveas("OtherName.doc")
  5. obj1.visible=true
This will open a word instance, showing the document. Still, the word instance will be shown to the user, but the document will be opened from the server, and saved in the server (for what you might need some privileges). I dont remember, but my guess is that you can embed this 'Obj1' to some kind of OLE control in your webform.

HTH
Sep 18 '09 #4
Thank u kadghar, but OLE container control is not available for WinForms in VB 2005, this is the cause to use a WebBrowser... Besides I get my document, the problem is in the final dialog box remembering me to save when I have saved before...
Sep 18 '09 #5
kadghar
1,295 Expert 1GB
oh, that's easy, you can use the same code above. Just change the DisplayAlerts property to false:

Obj1.DisplayAlerts = False

HTH
Sep 21 '09 #6
I have tried to apply this code in my project without success.

Here is my code:

Expand|Select|Wrap|Line Numbers
  1. Dim WordApp As New MSWord.Application
  2. Dim doc As MSWord.Document
  3. Dim docobj As Object
  4.  
  5. Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.    Dim document As System.Windows.Forms.HtmlDocument
  7.    Dim strFileName As String = ("c:\myword.doc")
  8.    WebBrowser1.Navigate(strFileName)
  9.    document = WebBrowser1.Document
  10.    WordApplication.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone
  11. End Sub
  12.  
  13.  
  14. Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
  15.    docobj = Me.WebBrowser1.ActiveXInstance.document
  16.    If TypeOf (docobj) Is MSWord.Document Then
  17.        doc = docobj
  18.        doc.SaveAs("c:\anotherword.doc")
  19.    End If
  20. End Sub
  21.  
  22. Public Sub Close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_Volver.Click
  23.    WebBrowser1.Navigate("about:blank")
  24.    doc=nothing
  25.    docobj=nothing
  26.    WordApp.Quit()
  27.    WodApp=Nothing
  28. End Sub
  29.  
After the form is closed appears the dialog as always... I don't know if it's necessary to definy WordApp but I tried it to use DisplayAlerts.

I hope u will can help me... Thank u very much for your time and your interest.
Sep 22 '09 #7
kadghar
1,295 Expert 1GB
yes,

the only way to disable alerts, its with the application. This will do:

WordApp.DisplayAlerts = False
Sep 24 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Gary | last post by:
Hi, there, 1. I would like to open a word document in a MDI environment. Every time, a new window outside my MDI poped out and show the word document. Is there a method I can use to specify the...
1
by: a94ws7 | last post by:
I am trying to automate a digital signature process with Microsoft Word, I have experimented by loading the word document into word and then from there placing that document inside a picturebox so...
3
by: John Smith | last post by:
Hey folks, I've got a Windows C# application that generates a .doc file and then allows the user to preview it. I generate the file using the StreamWriter class and do a flush() and a close()...
1
by: JerryShea | last post by:
Hi, I am opening a word document (RTF) in a webbrowser control and automating it. Most automation features seem to work but when I execute: wordApp.ActiveDocument.PrintPreview() I get an...
3
by: peshekeedweller | last post by:
In VB.net, how can I use automation to open a word document in a word window as a child window of an MDI form? Thanks in advance.
5
by: lloyduh234 | last post by:
I need to display and allow the user to print a Word document from within a C# WinForm application. I'm using the ActiveX Browser control. The Word document displays correctly, but remains "locked"...
3
by: Dennis | last post by:
I would like to host a word document in a windows form. Can anyone give me any guidance on how to do this, i.e., a control that accepts and displays a word document? -- Dennis in Houston
2
by: Dean Richardson | last post by:
Hello, I am currently building a windows application in VB.NET. At the moment I have a word document saved locally which I open with the WebBrowser control. I cannot seem to save the changes...
0
by: Dean Richardson | last post by:
Hello, I am currently building a windows application in VB.NET. At the moment I have a word document saved locally which I open with the WebBrowser control. I cannot seem to save the...
1
by: =?Utf-8?B?SWdvcg==?= | last post by:
Hi ! I have a problem with WebControl I opened Microsoft Word document not directly, but in Visual Basic 6.0 WebBrowser control. When I selected with Range.Select any text the Saved property...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.