Set WordApp = New Word.Application
WordApp.Documents.Add
Set doc = WordApp.ActiveDocument
Set se1 = WordApp.Selection
With doc.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = CentimetersToPoints(2)
.BottomMargin = CentimetersToPoints(2)
.LeftMargin = CentimetersToPoints(2)
.RightMargin = CentimetersToPoints(2)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.5)
.FooterDistance = CentimetersToPoints(1.75)
.PageWidth = CentimetersToPoints(29.7)
.PageHeight = CentimetersToPoints(21)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
.LayoutMode = wdLayoutModeLineGrid
End With
字体:
wordApp.Selection.Font.Size = 9
'表格:
'本例只简单地设置了表格居中、自动调整表格列宽、表头居中、标题行重复、设置表格边框线、设置表格纵向居中
Temp_Table.Rows.Alignment = wdAlignRowCenter
Temp_Table.AutoFitBehavior wdAutoFitContent
Temp_Table.Rows(1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
Temp_Table.Rows(1).Range.Rows.HeadingFormat = wdToggle
Temp_Table.Borders(wdBorderLeft).LineWidth = wdLineWidth150pt
Temp_Table.Borders(wdBorderRight).LineWidth = wdLineWidth150pt
Temp_Table.Borders(wdBorderTop).LineWidth = wdLineWidth150pt
Temp_Table.Borders(wdBorderBottom).LineWidth = wdLineWidth150pt
Temp_Table.Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
'调用word打开word文档:
Dim wordApp As New Word.Application
Dim myDoc As Word.Document
wordApp = CreateObject("Word.Application")
With wordApp
.Visible = True
.Documents.Open(strPath)
End With
''释放变量
'wordApp.DisplayAlerts = False
'wordApp.Quit()
'myDoc = Nothing
'GC.Collect() '强制垃圾回收
'System.Runtime.InteropServices.Marshal.ReleaseC
'在表格里插入图片:
oTable.Rows(1).Cells(1).Range.InlineShapes.AddPicture("c: est.jpg")
WordApp.Documents.Add
Set doc = WordApp.ActiveDocument
Set se1 = WordApp.Selection
With doc.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = CentimetersToPoints(2)
.BottomMargin = CentimetersToPoints(2)
.LeftMargin = CentimetersToPoints(2)
.RightMargin = CentimetersToPoints(2)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.5)
.FooterDistance = CentimetersToPoints(1.75)
.PageWidth = CentimetersToPoints(29.7)
.PageHeight = CentimetersToPoints(21)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
.LayoutMode = wdLayoutModeLineGrid
End With
字体:
wordApp.Selection.Font.Size = 9
'表格:
'本例只简单地设置了表格居中、自动调整表格列宽、表头居中、标题行重复、设置表格边框线、设置表格纵向居中
Temp_Table.Rows.Alignment = wdAlignRowCenter
Temp_Table.AutoFitBehavior wdAutoFitContent
Temp_Table.Rows(1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
Temp_Table.Rows(1).Range.Rows.HeadingFormat = wdToggle
Temp_Table.Borders(wdBorderLeft).LineWidth = wdLineWidth150pt
Temp_Table.Borders(wdBorderRight).LineWidth = wdLineWidth150pt
Temp_Table.Borders(wdBorderTop).LineWidth = wdLineWidth150pt
Temp_Table.Borders(wdBorderBottom).LineWidth = wdLineWidth150pt
Temp_Table.Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
'调用word打开word文档:
Dim wordApp As New Word.Application
Dim myDoc As Word.Document
wordApp = CreateObject("Word.Application")
With wordApp
.Visible = True
.Documents.Open(strPath)
End With
''释放变量
'wordApp.DisplayAlerts = False
'wordApp.Quit()
'myDoc = Nothing
'GC.Collect() '强制垃圾回收
'System.Runtime.InteropServices.Marshal.ReleaseC
'在表格里插入图片:
oTable.Rows(1).Cells(1).Range.InlineShapes.AddPicture("c: est.jpg")