+ Reply to Thread
Results 1 to 6 of 6

Using EXCEL VBA to create word ,insert header in word, add textbox in header and fill pic

  1. #1
    Registered User
    Join Date
    04-27-2013
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    5

    Using EXCEL VBA to create word ,insert header in word, add textbox in header and fill pic

    Hello,
    I'm using EXCEL VBA to create word ,insert header in word and add textbox in header, then,fill picture in the textbox. I finished The former steps , but I can not insert picture into textbox in the header using EXCEL VBA through the function of fill.picture or inlineaddpicture.Is there any way or example to display the step?
    Best Regards,
    Roger

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: Using EXCEL VBA to create word ,insert header in word, add textbox in header and fill

    Roger

    Can you post the code you have so far?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    04-27-2013
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Using EXCEL VBA to create word ,insert header in word, add textbox in header and fill

    Hi, Norie
    Thank you for your reply, but I'm sorry I have no code for this problem now. I deal with some works using EXCEL VBA, so I put it in my working pc. There is the code I found in the forum and my code is similar to it.
    [/php]

    Sub CreateWordDocWithHeader()
    Dim WApp As Word.Application
    Dim WDoc As Word.Document
    Dim WRng As Word.Range

    Set WApp = New Word.Application
    WApp.Visible = False

    Filename = "C:\Users\hyl24065\Desktop\dev\test.doc"

    Set WDoc = WApp.Documents.Add
    WDoc.SaveAs Filename

    Set WRng = WDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range
    WDoc.Shapes.AddTextbox(msoTextOrientationHorizontal, 120#, 27#, 72#, 63#).Select

    WDoc.Shapes(1).Fill.UserPicture "C:\Users\hyl24065\Desktop\dev\test.JPG"

    Set WRng = Nothing
    Set WDoc = Nothing
    Set WApp = Nothing
    End Sub

    [/php]

    The above code can be inserted textbox and picture into the word, but not the header in word. The textbox produced by my code can be added to header in word, but can not be filled picture into textbox. I'm new to EXCEL VBA and have no idea. Can you help me, Norie ? Thank you.

  4. #4
    Registered User
    Join Date
    04-27-2013
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Using EXCEL VBA to create word ,insert header in word, add textbox in header and fill

    Hi, Norie
    Thank you for your reply, but I'm sorry I have no code for this problem now. I deal with some works using EXCEL VBA, so I put it in my working pc. There is the code I found in the forum and my code is similar to it.
    [/php]

    Sub CreateWordDocWithHeader()
    Dim WApp As Word.Application
    Dim WDoc As Word.Document
    Dim WRng As Word.Range

    Set WApp = New Word.Application
    WApp.Visible = False

    Filename = "C:\Users\hyl24065\Desktop\dev\test.doc"

    Set WDoc = WApp.Documents.Add
    WDoc.SaveAs Filename

    Set WRng = WDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range
    WDoc.Shapes.AddTextbox(msoTextOrientationHorizontal, 120#, 27#, 72#, 63#).Select

    WDoc.Shapes(1).Fill.UserPicture "C:\Users\hyl24065\Desktop\dev\test.JPG"

    Set WRng = Nothing
    Set WDoc = Nothing
    Set WApp = Nothing
    End Sub

    [/php]

    The above code can be inserted textbox and picture into the word, but not the header in word. The textbox produced by my code can be added to header in word, but can not be filled picture into textbox. I'm new to EXCEL VBA and have no idea. Can you help me, Norie ? Thank you.

  5. #5
    Registered User
    Join Date
    04-27-2013
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Using EXCEL VBA to create word ,insert header in word, add textbox in header and fill

    Quote Originally Posted by Norie View Post
    Roger

    Can you post the code you have so far?

    Hi, Norie
    Thank you for your reply, but I'm sorry I have no code for this problem now. I deal with some works using EXCEL VBA, so I put it in my working pc. There is the code I found in the forum and my code is similar to it.
    [/php]

    Sub CreateWordDocWithHeader()
    Dim WApp As Word.Application
    Dim WDoc As Word.Document
    Dim WRng As Word.Range

    Set WApp = New Word.Application
    WApp.Visible = False

    Filename = "C:\Users\hyl24065\Desktop\dev\test.doc"

    Set WDoc = WApp.Documents.Add
    WDoc.SaveAs Filename

    Set WRng = WDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range
    WDoc.Shapes.AddTextbox(msoTextOrientationHorizontal, 120#, 27#, 72#, 63#).Select

    WDoc.Shapes(1).Fill.UserPicture "C:\Users\hyl24065\Desktop\dev\test.JPG"

    Set WRng = Nothing
    Set WDoc = Nothing
    Set WApp = Nothing
    End Sub

    [/php]

    The above code can be inserted textbox and picture into the word, but not the header in word. The textbox produced by my code can be added to header in word, but can not be filled picture into textbox. I'm new to EXCEL VBA and have no idea. Can you help me, Norie ? Thank you.

  6. #6
    Registered User
    Join Date
    04-27-2013
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Using EXCEL VBA to create word ,insert header in word, add textbox in header and fill

    Quote Originally Posted by Norie View Post
    Roger

    Can you post the code you have so far?
    Hi, Norie
    Thank you for your reply, but I'm sorry I have no code for this problem now. I deal with some works using EXCEL VBA, so I put it in my working pc. There is the code I found in the forum and my code is similar to it.
    Please Login or Register  to view this content.
    The above code can be inserted textbox and picture into the word, but not the header in word. The textbox produced by my code can be added to header in word, but can not be filled picture into textbox. I'm new to EXCEL VBA and have no idea. Can you help me, Norie ? Thank you.

  7. #7
    Registered User
    Join Date
    04-27-2013
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Using EXCEL VBA to create word ,insert header in word, add textbox in header and fill

    Quote Originally Posted by Norie View Post
    Roger

    Can you post the code you have so far?
    Hi, Norie,
    The following is my code, can you help me ? How to insert picture into textbox in header of word file by EXCEL VBA?


    Please Login or Register  to view this content.
    Last edited by xiaorenwuhyl; 04-28-2013 at 05:36 AM. Reason: wrong

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1