FanPages - Word Doc continued

Hi fp,

  Situation has altered a little with this app. Is there a way to Save the currently open Doc file without having to reload it? I can find the filename easily enough to determine that the correct Doc is being saved. If Cust makes some changes, then hits 'Email this Doc', I need to make sure the open Doc is saved before processing it.

  Thanks again.

TJ
tvtechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Harisha M GEngineerCommented:
Hi tvtech, in the code for "Email this Doc" put this line..

    ThisDocument.Save



---
Harish
tvtechAuthor Commented:
Hi mgh_mgharish,

  The question refers to the code at http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21673639.html.
Wouldn't I need to re-open the Doc again, even though it's already open?

  Thanks.

TJ
Harisha M GEngineerCommented:
Oh.. sorry, yes. You can't update it without reopening the document after saving.
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

tvtechAuthor Commented:
500 points to anyone who can answer this question in a hurry.

Thanks.

TJ
tvtechAuthor Commented:
More information ...

  I open a Doc file, using the following code and save it as another name. I need to be able to Save the current Doc file (Not the orignal) whenever I need to, even though the Doc will be open, as the User can make changes to the Doc whenever he/she likes.

  The code I use to handle the code is as follows:

*************************
'/Code start
*************************

  Dim objWord_Application                               As Object
   
    Set objWord_Application = CreateObject("Word.Application")
   
    ' Un-comment the next line to see the Word document creation on-screen, otherwise, to hide it, leave the next line alone...
     objWord_Application.Visible = True
   
'/Open my template Doc
    objWord_Application.Documents.Open ("C:\MyPath\MyDoc.Doc")
   
    objWord_Application.selection.Find.ClearFormatting
    objWord_Application.selection.Find.Text = "Name/Description:"
objWord_Application.Selection.Find.Forward = True               ' *** ADDED
objWord_Application.Selection.Find.Wrap = 1&                    ' wdFindContinue *** ADDED
    objWord_Application.selection.Find.Execute
    objWord_Application.selection.MoveRight Unit:=12&              ' wdCell
    objWord_Application.selection.TypeText Text:=CustName
   
    objWord_Application.selection.Find.ClearFormatting
    objWord_Application.selection.Find.Text = "Address:"
objWord_Application.Selection.Find.Forward = True               ' *** ADDED
objWord_Application.Selection.Find.Wrap = 1&                    ' wdFindContinue *** ADDED
    objWord_Application.selection.Find.Execute
    objWord_Application.selection.MoveRight Unit:=12&              ' wdCell
    objWord_Application.selection.TypeText Text:=Address
   
    objWord_Application.selection.Find.ClearFormatting
    objWord_Application.selection.Find.Text = "Est Load:"
objWord_Application.Selection.Find.Forward = True               ' *** ADDED
objWord_Application.Selection.Find.Wrap = 1&                    ' wdFindContinue *** ADDED
    objWord_Application.selection.Find.Execute
    objWord_Application.selection.MoveRight Unit:=12&              ' wdCell
    objWord_Application.selection.TypeText Text:=eLoad
   
    objWord_Application.selection.Find.ClearFormatting
    objWord_Application.selection.Find.Text = "Estimated Commissioning Date:"
objWord_Application.Selection.Find.Forward = True               ' *** ADDED
objWord_Application.Selection.Find.Wrap = 1&                    ' wdFindContinue *** ADDED
    objWord_Application.selection.Find.Execute
    objWord_Application.selection.MoveRight Unit:=12&              ' wdCell
    objWord_Application.selection.TypeText Text:=EstDate
       
    objWord_Application.selection.Find.ClearFormatting
    objWord_Application.selection.Find.Text = "Plant Requirements:"
objWord_Application.Selection.Find.Forward = True               ' *** ADDED
objWord_Application.Selection.Find.Wrap = 1&                    ' wdFindContinue *** ADDED
    objWord_Application.selection.Find.Execute
    objWord_Application.selection.MoveRight Unit:=12&              ' wdCell
    objWord_Application.selection.TypeText Text:=Plant
       
    objWord_Application.selection.Find.ClearFormatting
    objWord_Application.selection.Find.Text = "Zone Substation:"
objWord_Application.Selection.Find.Forward = True               ' *** ADDED
objWord_Application.Selection.Find.Wrap = 1&                    ' wdFindContinue *** ADDED
    objWord_Application.selection.Find.Execute
    objWord_Application.selection.MoveRight Unit:=12&              ' wdCell
    objWord_Application.selection.TypeText Text:=SubStation
   
    objWord_Application.selection.Find.ClearFormatting
    objWord_Application.selection.Find.Text = "Upstream Isolator:"
objWord_Application.Selection.Find.Forward = True               ' *** ADDED
objWord_Application.Selection.Find.Wrap = 1&                    ' wdFindContinue *** ADDED
    objWord_Application.selection.Find.Execute
    objWord_Application.selection.MoveRight Unit:=12&              ' wdCell
    objWord_Application.selection.TypeText Text:=UpIS
   
    objWord_Application.selection.Find.ClearFormatting
    objWord_Application.selection.Find.Text = "Downstream Isolator:"
objWord_Application.Selection.Find.Forward = True               ' *** ADDED
objWord_Application.Selection.Find.Wrap = 1&                    ' wdFindContinue *** ADDED
    objWord_Application.selection.Find.Execute
    objWord_Application.selection.MoveRight Unit:=12&              ' wdCell
    objWord_Application.selection.TypeText Text:=DownIS
   
    objWord_Application.selection.Find.ClearFormatting
    objWord_Application.selection.Find.Text = "Feeder:"
objWord_Application.Selection.Find.Forward = True               ' *** ADDED
objWord_Application.Selection.Find.Wrap = 1&                    ' wdFindContinue *** ADDED
    objWord_Application.selection.Find.Execute
    objWord_Application.selection.MoveRight Unit:=12&              ' wdCell
    objWord_Application.selection.TypeText Text:=Fdr

    '/Scroll to top of Doc
    objWord_Application.selection.HomeKey Unit:=6&
   
    '/Save Doc as new filename, based on Custname and Address
    objWord_Application.ActiveDocument.SaveAs "C:\MyPath\MyNew.Doc"
       
    '/Close original doc name that we opened to begin with
    objWord_Application.Documents.Close "C:\MyPath\MyDoc.Doc"
   
    '/Ensure active document is visible
    objWord_Application.ActiveDocument
   
    '/Clear Doc object from memory
    Set objWord_Application = Nothing

Any questions, let me know.

Regards,
  TJ
bruintjeCommented:
Hello tvtech,

probably missing something but why not derive your new document from the template in the first place that way you don't have to deal with the template and your new document is the one open at the moment

Dim doc As Object

Set doc = objWord_Application.Documents.Add ("C:\MyPath\MyDoc.Doc")
doc.SaveAs "c:\mynewfile.doc"

etc.....

hope this helps a bit and a happy new year!
bruintje

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GrahamSkanRetiredCommented:
It's not clear what the problem is. Of course you can save an open document.
And there isn't any point in opening a document merely to save it.
Harisha M GEngineerCommented:
GrahamSkan, what he wants is to load the contents of a document to another document, for which the first document is to be stored, reopened and then its contents are to be used by other one.
tvtechAuthor Commented:
I've actually found my own solution to this question, so if we can just close the question, it would be appreciated.

Regards,
  TJ
GrahamSkanRetiredCommented:
Harish, Thanks for the explanation.

If you need two copies of a document, then doing SaveAs twice would seem the simplest thing to do.

However, I see that you now say that you have found your own solution.

If you want a points refund, you can request that with a question in the Community Support area. To be eligible, you would usually be expected to have provided an explanation here.
tvtechAuthor Commented:
Frankly, if no one has been able to answer the question and the person who asked it has found the answer themselves, I don't see why that person should be required to publish his solution to get a refund that no one actually deserved the points for. :-( The only reason I can see that requirement would be for the owners of E-E to make a buck when either selling CD's, or selling Premium accounts.
E-E is not so much about free info exchange, as it is about creating a money driven info exchange, which is fair enough, but giving up info for non-earned points (refund) is a bit wrong as far as I'm concerned.

bruintje, it's all yours. Too much hassle to go through the refund process.

TJ
bruintjeCommented:
TJ, thanks even though i think it is a good solution this leaves open for a reader what you used to solve this one

so awarding the points for something that could be or could be not related to the solution is not ok, i'll post a cs q myself to refund your points
tvtechAuthor Commented:
bruintje, I used part of your solution, so no, that would be unfair. Leave the points as they are.
Thanks.
bruintjeCommented:
ok :)
GrahamSkanRetiredCommented:
tvtech,

I suppose that the reason that questioners are expected to publish their solution in order to get a refund is that it is otherwise quite easy to take and use one of the offered solutions and simply make the claim that they have found their own answer.
tvtechAuthor Commented:
GrahamSkan,

  Yes, I thought of that as I was typing and would normally agree, but in most cases, the Moderator has the experience to look at the original question, check the answers and then make an informed decision as to whether any of the answers comes close to the solution requested. At any rate, in 8yrs of membership, I have never had a question gone unanswered until now, so, 1 out of 9 ain't bad.  :-)

Thanks for your input.

TJ
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.