batman7570
New Member
- Joined
- Sep 10, 2016
- Messages
- 8
Dear all,
Hi , everyone. i am a beginner to VBA and creating new macro to facilitate my work.
i am doing administration work in my company. Everyday , i need to receive document(in word format) from to whole company and check their format (e.g font size, margin,.....) Then, i come up with two solution , the first one is to create a VBA /macro in excel format then move those content to the word format.The second one is to create a VBA/macro in word so that once i launch the vba, it would change the format of word into what i want.
For solution one, i have already find some code like that:
"Sub Example1()
Dim objWord As Object
Dim objDoc As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add
Dim i As Integer
Dim strValue As String
For i = 1 To 6
'bring focus to the document created
objDoc.Activate
'read the value from the cell
strValue = Cells(i + 1, 1)
'write the value to the document
objWord.Selection.TypeText Text:=strValue
'move to the next line
objWord.Selection.TypeParagraph
Next i
End Sub"
this code is great , however, i would like to know (1) if i want to create a table in excel then send it to word, how can i write the code?(2)if i want to send a photo from excel to word, what is the code?
For solution 2
(1)i found there is lack of information related to word vba.(2)i would like to know if there is example that someone write a VBA/macro to regulate the format of the word document.
thank you everyone, it is a very good website , i learn a lot from that.
Hi , everyone. i am a beginner to VBA and creating new macro to facilitate my work.
i am doing administration work in my company. Everyday , i need to receive document(in word format) from to whole company and check their format (e.g font size, margin,.....) Then, i come up with two solution , the first one is to create a VBA /macro in excel format then move those content to the word format.The second one is to create a VBA/macro in word so that once i launch the vba, it would change the format of word into what i want.
For solution one, i have already find some code like that:
"Sub Example1()
Dim objWord As Object
Dim objDoc As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add
Dim i As Integer
Dim strValue As String
For i = 1 To 6
'bring focus to the document created
objDoc.Activate
'read the value from the cell
strValue = Cells(i + 1, 1)
'write the value to the document
objWord.Selection.TypeText Text:=strValue
'move to the next line
objWord.Selection.TypeParagraph
Next i
End Sub"
this code is great , however, i would like to know (1) if i want to create a table in excel then send it to word, how can i write the code?(2)if i want to send a photo from excel to word, what is the code?
For solution 2
(1)i found there is lack of information related to word vba.(2)i would like to know if there is example that someone write a VBA/macro to regulate the format of the word document.
thank you everyone, it is a very good website , i learn a lot from that.