Link to home
Start Free TrialLog in
Avatar of tvtech
tvtechFlag for Australia

asked on

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
Avatar of Harisha M G
Harisha M G
Flag of India image

Hi tvtech, in the code for "Email this Doc" put this line..

    ThisDocument.Save



---
Harish
Avatar of tvtech

ASKER

Hi mgh_mgharish,

  The question refers to the code at https://www.experts-exchange.com/questions/21673639/Populate-Doc-file-with-data-from-VB.html.
Wouldn't I need to re-open the Doc again, even though it's already open?

  Thanks.

TJ
Oh.. sorry, yes. You can't update it without reopening the document after saving.
Avatar of tvtech

ASKER

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

Thanks.

TJ
Avatar of tvtech

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.
Avatar of tvtech

ASKER

I've actually found my own solution to this question, so if we can just close the question, it would be appreciated.

Regards,
  TJ
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.
Avatar of tvtech

ASKER

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
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
Avatar of tvtech

ASKER

bruintje, I used part of your solution, so no, that would be unfair. Leave the points as they are.
Thanks.
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.
Avatar of tvtech

ASKER

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