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 / October 2007

Tip: Looking for answers? Try searching our database.

still nothing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
matthew.rodwell@luptonfawcett.com - 30 Oct 2007 08:05 GMT
I couldn't get this to work still....i;m not sure if i am doing it
correctly.

Dim doc1 in the 1st one and the doc1 = Activedocument added intot he
script then the same in 2.....but i still don't know the code to
switch back from the second document which is loaded last back to the
main.,

not copied it all cos its huge

Private Sub cmdOK_Click()
   'If the OK button is clicked

doc2 = Documents.Add("C:\OFFICE\WORD\TEMPLATES\bill3.dot")

With ActiveDocument
Selection.WholeStory
Selection.PasteAndFormat (wdPasteDefault)
Selection.HomeKey Unit:=wdStory
   'Goes into the header
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
   'Inserts the AutoText
Selection.TypeText Text:="NotVAT"
Selection.Range.InsertAutoText
   'Goes back into the body of the document
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

End With

Unload frmBill

End Sub
Russ - 30 Oct 2007 10:30 GMT
Matthew,
You shouldn't break the message thread by using a new subject line.

See how to use Option Explicit:
http://word.mvps.org/faqs/macrosvba/DeclareVariables.htm

It looks like you are opening Doc2 in the UserForm cmdOK_Click().
Well, you could at the top of that subroutine use the code.
Dim Doc1 as Word.Document
Dim Doc2 as Word.Document

Set Doc1 = ActiveDocument
Set doc2 = Documents.Add("C:\OFFICE\WORD\TEMPLATES\bill3.dot")
.....

Then at the end of that subroutine before unloading Userform use the code.

Doc1.Activate

> I couldn't get this to work still....i;m not sure if i am doing it
> correctly.
[quoted text clipped - 8 lines]
> Private Sub cmdOK_Click()
>     'If the OK button is clicked

Dim Doc1 as Word.Document
Dim Doc2 as Word.Document

Doc1 = ActiveDocument
Set doc2 = Documents.Add("C:\OFFICE\WORD\TEMPLATES\bill3.dot")

> Set doc2 = Documents.Add("C:\OFFICE\WORD\TEMPLATES\bill3.dot")
>
[quoted text clipped - 11 lines]
>
> End With

Doc1.Activate

> Unload frmBill
>
> End Sub

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

matthew.rodwell@luptonfawcett.com - 30 Oct 2007 17:35 GMT
I thank you greatly sorry about the double post haven't used this for
ages..works a treat now

Rate this thread:






 
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.