Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Saving a document created with vb in word

Posted on 2000-02-21
8
Medium Priority
?
189 Views
Last Modified: 2010-05-02
i have externally created a word document from my vb application, and it has opened word, added a document (documents.add) and written stuff to the selection.

how do you save the document without a prompt as a certain filename... i dont want it to be called "document 1.txt" or anything like that. OR... if i MUST have a prompt, (as in, if i just go.. documents.save true, true) how do i allow it to overwrite files already there?

thanx
0
Comment
Question by:Sesh
  • 4
  • 2
  • 2
8 Comments
 

Expert Comment

by:amuru
ID: 2544491
Do u want to save the word.doc without any prompt ???
0
 

Author Comment

by:Sesh
ID: 2544493
yes... i want to save it as a specific filename without prompting

also, how do you kill off the application when you are finished with it... is there a Word.Application.Close?
0
 

Author Comment

by:Sesh
ID: 2544498
yes... i want to save it as a specific filename without prompting

also, how do you kill off the application when you are finished with it... is there a Word.Application.Close?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 70

Accepted Solution

by:
Éric Moreau earned 400 total points
ID: 2544525
This code saves without prompting the user and quit.

Private Sub Command2_Click()
Dim objWord As Word.Application

    Set objWord = New Word.Application
   
    With objWord
        .Visible = True
        .Documents.Add
        .ActiveDocument.Select
        .Selection.InsertAfter "Hello"
        .ActiveDocument.SaveAs App.Path & "\t.doc"
        .Quit False
    End With
    Set objWord = Nothing
End Sub
0
 

Expert Comment

by:amuru
ID: 2544577
wdPromptToSaveChanges, or wdSaveChanges

Change the below Prompt to save without prompt :

On Error GoTo errorHandler
ActiveDocument.Close SaveChanges:=wdPromptToSaveChanges, OriginalFormat:=wdPromptUser
errorHandler:
If Err = 4198 Then MsgBox "Document was not closed"

to kill the Application use :
goWord.quit

set goWord = Nothing

Above is just the command to close opened word.  Add some coding to check activedocument.
0
 

Author Comment

by:Sesh
ID: 2553543
thanx a lot for that... its exactly what i was looking for

just one other thing, though... how do you insert tabs, create tabstops and insert those horizontal lines that appear when you type

---------

on a new line????

help in this would be really great.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2555144
I never played with tabs by automation so can't help on this one.

About your horizontal lines: which lines???
0
 

Author Comment

by:Sesh
ID: 2563899
dont worry.. i figured it out. :)

i was referring to the wdBorderTop..
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question