Solved

Saving a document created with vb in word

Posted on 2000-02-21
8
180 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 70

Accepted Solution

by:
Éric Moreau earned 100 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pull multiple cvs files into one access table 28 68
using Access 8 68
Put text in a picture ASP.NET C# 2 56
Notepad++ how to remove delimiter : from beggning of the line? 3 100
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

813 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now