still nothing

M

matthew.rodwell

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
 
R

Russ

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.

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

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

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

matthew.rodwell

I thank you greatly sorry about the double post haven't used this for
ages..works a treat now
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top