Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2007

Tip: Looking for answers? Try searching our database.

Copy and paste

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LEU - 16 Feb 2007 01:51 GMT
I was going through all the questions posted on coping and found almost what
I was looking for under a response by Doug Robbins. What I have is as follows:

Private Sub Copy1_Click()
With ActiveDocument
.Variables("varA").Value = Cmb1.Value
.Variables("varB").Value = Text1.Text
etc
.SaveAs ("c:\TempA")
End With
End Sub

Private Sub Paste1_Click()
Dim DocA As Document
Set DocA = Documents.Open("c:\TempA")
With DocA
Text1.Text = .Variables("varA").Value
Cmb1.Text = .Variables("varB").Value
etc
DocA.Close wdDoNotSaveChanges
End With
End Sub

My questions are in my Copy1_Click() how do I close "c:\TempA" after its
saved and in my Paste1_Click() how do I delete TempA when I’m done?
Jezebel - 16 Feb 2007 02:42 GMT
>I was going through all the questions posted on coping and found almost
>what
[quoted text clipped - 23 lines]
> My questions are in my Copy1_Click() how do I close "c:\TempA" after its
> saved and in my Paste1_Click() how do I delete TempA when I'm done?

1.
   .Close

2.
   Kill "c:\TempA.doc"
LEU - 16 Feb 2007 03:14 GMT
The Kill "c:\TempA.doc" worked great.

On the .close it closes both my active document and "c:\TempA.doc". Is there
a way to just close "c:\TempA.doc"?

Thank you for the help.
LEU

> >I was going through all the questions posted on coping and found almost
> >what
[quoted text clipped - 29 lines]
> 2.
>     Kill "c:\TempA.doc"
Jezebel - 16 Feb 2007 03:22 GMT
> On the .close it closes both my active document and "c:\TempA.doc". Is
> there
> a way to just close "c:\TempA.doc"?

You use the close method on the object that represents it. ActiveDocument in
the sample you post.

With ActiveDocument
   :
   .Close
End with

or simply ActiveDocument.Close

> Thank you for the help.
> LEU
[quoted text clipped - 33 lines]
>> 2.
>>     Kill "c:\TempA.doc"
LEU - 17 Feb 2007 04:31 GMT
When I do the following both the ActiveDocumnet and ("c:\TempA") close. I
would like to keep the ActiveDocument open and just close ("c:\TempA"). Is
that possible?

Private Sub Copy1_Click()
With ActiveDocument
.Variables("varA").Value = Cmb1.Value
.Variables("varB").Value = Text1.Text
etc
.SaveAs ("c:\TempA")
.close
End With
End Sub

> > On the .close it closes both my active document and "c:\TempA.doc". Is
> > there
[quoted text clipped - 47 lines]
> >> 2.
> >>     Kill "c:\TempA.doc"
Jezebel - 17 Feb 2007 08:33 GMT
Yes, of course it's possible. Read Help on document objects and their
methods.

> When I do the following both the ActiveDocumnet and ("c:\TempA") close. I
> would like to keep the ActiveDocument open and just close ("c:\TempA"). Is
[quoted text clipped - 64 lines]
>> >> 2.
>> >>     Kill "c:\TempA.doc"
LEU - 17 Feb 2007 21:50 GMT
I’m stuck. I have looked at the help on document objects and their methods. I
thought I had it figured out, but I don’t. Here are the steps I am following:

1  I open my existing document.
2  I click on my CommandButton to open form
3  I click on my Copy button which I want to copy the fields in the form
using the following macro:

Private Sub Copy1_Click()
With ActiveDocument
.Variables("varA").Value = Cmd1.Value
.Variables("varB").Value = Text1.Text
etc
.SaveAs ("c:\TempA")
Documents("c:\TempA.doc").Close SaveChanges:=wdSaveChanges
End With
End Sub

This saves and closes TempA.Doc. It looks like using the ‘SaveAs’ is taking
my original document and making it TempA so when TempA closes there is no
original document still open. How do I keep my original existing document
open?

> Yes, of course it's possible. Read Help on document objects and their
> methods.
[quoted text clipped - 67 lines]
> >> >> 2.
> >> >>     Kill "c:\TempA.doc"
LEU - 17 Feb 2007 23:18 GMT
After talking to the group that request this I found out that the original
really does not need to stay open. So my code works fine as is.

Jezebel, I want to thank you for you help. I am glad that people like you
are out there and willing to help.

> I’m stuck. I have looked at the help on document objects and their methods. I
> thought I had it figured out, but I don’t. Here are the steps I am following:
[quoted text clipped - 90 lines]
> > >> >> 2.
> > >> >>     Kill "c:\TempA.doc"
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.