instruction for opening a file with VBA

T

troubadour

i am a newby and i can't find the syntax, any help ?

dim MyFile as string
MyFile = "c:\MyDir\MyDoc.doc"
open (MyFile, etc...) (it does not work as such...)

Where is the error ? (I have no help file installed yet)
Thank you

Troubadour
 
H

Helmut Weber

Documents.Open MyFile


Greetings from Bavaria, Germany

Helmut Weber, MVP, WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
T

troubadour

Thank you. Could you help me just a little bit more :
The name of the file i wish to open is in the clipboard.
My syntax seems to wrong :

Dim MyFile as string
MyFile = getFromClipboard() [i think i need a prefix here, but what kind ?]
or MyFile.getFromClipboard() ???
Documents.Open MyFile

Thank you for help
 
J

Jonathan West

troubadour said:
Thank you. Could you help me just a little bit more :
The name of the file i wish to open is in the clipboard.
My syntax seems to wrong :

Dim MyFile as string
MyFile = getFromClipboard() [i think i need a prefix here, but what kind
?]
or MyFile.getFromClipboard() ???
Documents.Open MyFile

Thank you for help

This article tells you how to do this

Manipulating the clipboard using VBA
http://www.word.mvps.org/FAQs/MacrosVBA/ManipulateClipboard.htm


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
T

troubadour

Thank you for the useful and clear web page.
Where is the mistake now ? (I have now an empty userform in the project, but
no possible reference here to MS Forms 2.0 object library)

Type DataObject
toto As Object
End Type
________________________
Sub MyTest()
Dim MyData As DataObject
Dim strClip As String
Set MyData = New DataObject (compiler error here : incorrect use of
the “new†keyword )
MyData.GetFromClipboard
strClip = MyData.GetText
MsgBox (strClip)
End Sub
___________________________

Thank you for help again

Troubadour



Jonathan West said:
troubadour said:
Thank you. Could you help me just a little bit more :
The name of the file i wish to open is in the clipboard.
My syntax seems to wrong :

Dim MyFile as string
MyFile = getFromClipboard() [i think i need a prefix here, but what kind
?]
or MyFile.getFromClipboard() ???
Documents.Open MyFile

Thank you for help

This article tells you how to do this

Manipulating the clipboard using VBA
http://www.word.mvps.org/FAQs/MacrosVBA/ManipulateClipboard.htm


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
J

Jonathan West

You don't want the Type Dataobject block in your code.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org


troubadour said:
Thank you for the useful and clear web page.
Where is the mistake now ? (I have now an empty userform in the project,
but
no possible reference here to MS Forms 2.0 object library)

Type DataObject
toto As Object
End Type
________________________
Sub MyTest()
Dim MyData As DataObject
Dim strClip As String
Set MyData = New DataObject (compiler error here : incorrect use of
the “new†keyword )
MyData.GetFromClipboard
strClip = MyData.GetText
MsgBox (strClip)
End Sub
___________________________

Thank you for help again

Troubadour



Jonathan West said:
troubadour said:
Thank you. Could you help me just a little bit more :
The name of the file i wish to open is in the clipboard.
My syntax seems to wrong :

Dim MyFile as string
MyFile = getFromClipboard() [i think i need a prefix here, but what
kind
?]
or MyFile.getFromClipboard() ???
Documents.Open MyFile

Thank you for help

This article tells you how to do this

Manipulating the clipboard using VBA
http://www.word.mvps.org/FAQs/MacrosVBA/ManipulateClipboard.htm


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
T

troubadour

Where is the mistake ? (I have now an empty userform in the project, but no
possible reference here to MS Forms 2.0 object library)

Type DataObject
toto As Object
End Type
________________________
Sub MyTest()
Dim MyData As DataObject
Dim strClip As String
Set MyData = New DataObject (compiler error : incorrect use of the
“new†keyword )
MyData.GetFromClipboard
strClip = MyData.GetText
MsgBox (strClip)
End Sub
___________________________

Thank you for help




Jonathan West said:
troubadour said:
Thank you. Could you help me just a little bit more :
The name of the file i wish to open is in the clipboard.
My syntax seems to wrong :

Dim MyFile as string
MyFile = getFromClipboard() [i think i need a prefix here, but what kind
?]
or MyFile.getFromClipboard() ???
Documents.Open MyFile

Thank you for help

This article tells you how to do this

Manipulating the clipboard using VBA
http://www.word.mvps.org/FAQs/MacrosVBA/ManipulateClipboard.htm


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

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

Top