D
dan
Can anyone help???
I'm trying to write a simple macro which will replace text in my document
with a file. The text in the document is the filename to be inserted.
This is what I've written so far:
Sub INSERT_FILE()
'
' INSERT_FILE Macro
' Macro recorded 11/10/2006 by daniel.mee
'
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Copy
Dim myString As String
Dim myString2 As String
myString = Selection
myString2 = "C:\MyDocuments && selection &&"
Selection.InlineShapes.AddOLEObject ClassType:="Package",
FileName:=myString2, LinkToFile:=False, DisplayAsIcon:=True, IconFileName:= _
"C:\WINDOWS\NOTEPAD.EXE", IconIndex:=0, IconLabel:= _
myString
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
End Sub
It all falls apart where I try to assign the strings. I basically want to
paste the data which I've copied from the text into one string, have the path
in another string and then concatenate the two strings and use them to Fill
in the FileName field in the insert object pop-up box.
Any suggestions on how to achieve this?? I also want to rename the caption
of the inserted object to the filename (myString variable).
Thanks in advance
I'm trying to write a simple macro which will replace text in my document
with a file. The text in the document is the filename to be inserted.
This is what I've written so far:
Sub INSERT_FILE()
'
' INSERT_FILE Macro
' Macro recorded 11/10/2006 by daniel.mee
'
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Copy
Dim myString As String
Dim myString2 As String
myString = Selection
myString2 = "C:\MyDocuments && selection &&"
Selection.InlineShapes.AddOLEObject ClassType:="Package",
FileName:=myString2, LinkToFile:=False, DisplayAsIcon:=True, IconFileName:= _
"C:\WINDOWS\NOTEPAD.EXE", IconIndex:=0, IconLabel:= _
myString
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
End Sub
It all falls apart where I try to assign the strings. I basically want to
paste the data which I've copied from the text into one string, have the path
in another string and then concatenate the two strings and use them to Fill
in the FileName field in the insert object pop-up box.
Any suggestions on how to achieve this?? I also want to rename the caption
of the inserted object to the filename (myString variable).
Thanks in advance