opening a word file

rodney_malodney

Board Regular
Joined
Jul 19, 2005
Messages
116
the word file is open and is saved as a name that come from user input and in the code is named:
fname (with .dot behind it )
or
prname (no .dot)

how do i call the file:

windows. (prname).activate doesnt work so what does???

Code:
Private Sub CommandButton1_Click()
'
'yes i can do word as well, this took hours...
'
Dim prname As String
Dim docnew As Document
Dim fname As String
Dim details(0)

setdocnew = Documents.Add

'

prname = InputBox("Please Confirm Project Name/Number, (this MUST match the name given on the project folder")
'
fname = prname & ".doc"
details(0) = fname
With docnew

ActiveDocument.SaveAs FileName:=fname
End With




'
'in theory this should copy all the templates form their seperate folders to the one single folder named prname or fname
'


If CheckBox1 = True Then
Documents.Open FileName:="erectorsinstructions.dot", ConfirmConversions:=False, _
        ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
        PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
        WritePasswordTemplate:="", Format:=wdOpenFormatAuto

 Windows(prname).Activate
    Windows("erectorsinstructions").Activate
    Selection.WholeStory
    Selection.Copy
    Windows(prname).Activate
    Selection.Paste
    Windows("a code").Activate

    

End If


End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
ive got this but i get an error "the requested member of the collection does not exist" - eh?!!!! im begging to loose hope :( come on mr excel save me again, plz

Private Sub CommandButton1_Click()
'
'yes, i can do word as well, this took hours...
'
Dim prname As String
Dim docnew As Document
Dim fname As String
Dim details(1)
Dim final As String
'
setdocnew = Documents.Add
'
'
'
prname = InputBox("Please Confirm Project Name/Number, (this MUST match the name given on the project folder)")
'
fname = prname & ".doc"
details(0) = fname
details(1) = prname
With docnew

ActiveDocument.SaveAs FileName:=fname
End With

'
'in theory this should copy all the templates from their seperate folders to the one single folder named prname or fname
'
final = prname
'
If CheckBox1 = True Then
Documents.Open FileName:="erectorsinstructions.dot", ConfirmConversions:= _
False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
Selection.WholeStory
Selection.Copy
Windows(prname).Activate
Selection.Paste
Windows("erectorsinstructions").Activate
ActiveWindow.Close


'



'
End If
'
End Sub
 
Upvote 0
????

I don't understand what you are asking.

If you are running this from Word, your question makes no sense.

"the word file is open and is saved as a name that come from user input and in the code is named:
fname (with .dot behind it )
or
prname (no .dot)

how do i call the file"

What do you mean by call the file? It's already open because you declared the new file and saved it. You didn't close it. It's the active doc in the active app.
 
Upvote 0
i see, but what do i refer to it as in the "Windows(prname).Activate " part of the code, or should i refer to it as something else????

cheers for your reply
 
Upvote 0

Forum statistics

Threads
1,224,829
Messages
6,181,224
Members
453,025
Latest member
Hannah_Pham93

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top