panda789
07-13-2015, 03:08 AM
Hi, i have a template with rounded rectangle shapes. My problem is this:
I need to export a list of names from a program, it saves a .doc file with for example, 20 names. I need to put the names in those shapes automatically, by creating a button for example, but i can't find a way to do that. I tried using the "Application.GetOpenFileName" function from excel VBA, but didn't work.
I uploaded the template file that needs to be filled with the names. I have a .doc file with the names too.
Any help would be appreciated.
Thanks, Tudor.
PS: This is what I tried in VBA word. It auto-fills the shapes with only one Name, the one I entered.
Private Sub CommandButton1_Click()
Dim shp As Shape
Dim str As String
Dim strFileName As String
For Each shp In ActiveDocument.Shapes
str = "WS-ASD-105-BB"
shp.TextFrame.TextRange.Text = str
shp.TextFrame.TextRange.Paragraphs.Alignment = wdAlignParagraphCenter
shp.TextFrame.TextRange.Font.Size = 24
shp.TextFrame.MarginTop = 35
Next
End Sub
I need to export a list of names from a program, it saves a .doc file with for example, 20 names. I need to put the names in those shapes automatically, by creating a button for example, but i can't find a way to do that. I tried using the "Application.GetOpenFileName" function from excel VBA, but didn't work.
I uploaded the template file that needs to be filled with the names. I have a .doc file with the names too.
Any help would be appreciated.
Thanks, Tudor.
PS: This is what I tried in VBA word. It auto-fills the shapes with only one Name, the one I entered.
Private Sub CommandButton1_Click()
Dim shp As Shape
Dim str As String
Dim strFileName As String
For Each shp In ActiveDocument.Shapes
str = "WS-ASD-105-BB"
shp.TextFrame.TextRange.Text = str
shp.TextFrame.TextRange.Paragraphs.Alignment = wdAlignParagraphCenter
shp.TextFrame.TextRange.Font.Size = 24
shp.TextFrame.MarginTop = 35
Next
End Sub