Hello,
I was wondering if someone could please help me out. I am trying to create a TextBox from Microsoft Excel into Microsoft Word using VB Script. Let me clarify this, if I am in Excel and click on something (whatever I decide to trigger the event) I want a new Word document opened and several things to happen, such as a picture getting copied from Excel into Word.
So far I am able to open and display a new word document. I am able to copy the picture from Excel into Word. Now I am trying to get a TextBox with text in it. I have created a TextBox, but cant figure out how to use script to manipulate it.
I have done similar stuff to this in script in Excel, not copping it to Word, and I dont have any issues. I would think the code would be similar to get stuff created in Word but cant seem to get anything to work. The main reason why I want a TextBox for is because I need to place text on a picture and I want that text to change, depending on what the value is in Excel.
Here is what I have so far and it works:
If I was doing this strictly in Excel, I would know how to do this. Can someone please tell me how to place text within this TextBox? Remember this script is in Excel and I need all of this stuff to run in a new Word document. I would also like to make the Borders and Fill invisible or empty in the TextBox. Once again I know how to do this in Excel, just cant figure it out in Word (or by having VB Script running in Excel to create this file as a Word document).
Thanks for any help someone can provide,
Zines
I was wondering if someone could please help me out. I am trying to create a TextBox from Microsoft Excel into Microsoft Word using VB Script. Let me clarify this, if I am in Excel and click on something (whatever I decide to trigger the event) I want a new Word document opened and several things to happen, such as a picture getting copied from Excel into Word.
So far I am able to open and display a new word document. I am able to copy the picture from Excel into Word. Now I am trying to get a TextBox with text in it. I have created a TextBox, but cant figure out how to use script to manipulate it.
I have done similar stuff to this in script in Excel, not copping it to Word, and I dont have any issues. I would think the code would be similar to get stuff created in Word but cant seem to get anything to work. The main reason why I want a TextBox for is because I need to place text on a picture and I want that text to change, depending on what the value is in Excel.
Here is what I have so far and it works:
Code:
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add
Sheets("Sheet1").Shapes("Picture1").Copy
wrdApp.Selection.Paste
With wrdDoc
.Shapes.AddTextBox(msoTextOrientationHorizontal, 40, 52, 96, 50).Name = "TextBox1"
End With
Thanks for any help someone can provide,
Zines