Solved

Saving a document created with vb in word

Posted on 2000-02-21
8
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

623 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