如何使用VB.NET将图片添加到标题 [英] How to add a picture to header with VB.NET

查看:99
本文介绍了如何使用VB.NET将图片添加到标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用VB.NET将图片添加到标题



我有代码添加页脚但我无法添加标题,你能帮助我吗?请:(



How to add a picture to header with VB.NET

I have code to add a footer but i can't add a header, can you help me please :(

oWord = DirectCast(CreateObject("Word.Application"), word.Application)
      oWord.Visible = False
      oDoc = oWord.Documents.Open("C:\exibit\Quotation No. " & usquot & "\" & a & ".docx")
      If oWord.ActiveWindow.View.SplitSpecial <> word.WdSpecialPane.wdPaneNone Then
          oWord.ActiveWindow.Panes(2).Close()
      End If
      If oWord.ActiveWindow.ActivePane.View.Type = word.WdViewType.wdNormalView Or _
          oWord.ActiveWindow.ActivePane.View.Type = word.WdViewType.wdOutlineView Then
          oWord.ActiveWindow.ActivePane.View.Type = word.WdViewType.wdPrintView
      End If
      oWord.ActiveWindow.ActivePane.View.SeekView = word.WdSeekView.wdSeekCurrentPageHeader
      If oWord.Selection.HeaderFooter.IsHeader = True Then
          oWord.ActiveWindow.ActivePane.View.SeekView = word.WdSeekView.wdSeekCurrentPageFooter
      Else
          oWord.ActiveWindow.ActivePane.View.SeekView = word.WdSeekView.wdSeekCurrentPageHeader

      End If
      oWord.Selection.ParagraphFormat.Alignment = word.WdParagraphAlignment.wdAlignParagraphJustifyHi
      oWord.Selection.TypeText(Text:="Project name: " & fMain.TextBox1.Text & vbTab & vbTab & "Page: ")
      oWord.Selection.Fields.Add(Range:=oWord.Selection.Range, Type:=word.WdFieldType.wdFieldPage)
      oWord.Selection.TypeText(Text:=vbNewLine & "Quotation No. " & fMain.TextBox13.Text)

      oWord.ActiveWindow.ActivePane.View.SeekView = word.WdSeekView.wdSeekMainDocument
      oDoc.Range.Font.Color = WdColor.wdColorBlack


      oDoc.Save()
      oDoc.Close()
      oDoc = Nothing
      oWord.Quit()
      oWord = Nothing

推荐答案

要在当前选择的位置添加图片,您可以使用 InlineShapes.AddPicture [ ^ ]。类似于:

To add a picture in the location of current selection you can use InlineShapes.AddPicture[^]. Something like:
oWord.Selection.InlineShapes.AddPicture( _
                  FileName := "C:\somedir\somefile.jpg", _
                  LinkToFile := False, _
                  SaveWithDocument:= True)


这篇关于如何使用VB.NET将图片添加到标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆