Using VB6 to transfer .BMP file to WORD 2003


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Using VB6 to transfer .BMP file to WORD 2003

  1. #1
    Join Date
    Jan 2005
    Location
    New Zealand
    Posts
    319

    Using VB6 to transfer .BMP file to WORD 2003

    Hi there,

    Need your help. I am using VB6 to transfer textboxes data from the Screen into the Text Form field in Word Document 2003. Transferring normal text does work well but trying to retrieve the Manager signature in .bmp format from the folder is not working. Being struggling for 3 days now but still no success in it.

    Here is my sample Vb6 script to retrieve the .BMP signature file from Folder:-

    dim oWord as Word.application
    dim oDoc as word.document
    dim strSignPath as string

    Set oWord = New Word.application
    Set oDoc = oWord.Documents.add("F:\SalesDept\SaleAppv.doc")

    oDoc.activate
    oWord.visible = true

    strSignPath = "F:\SaleDept\ScanSignature\JohnHill.bmp"

    With oDoc
    .formfields("MgmrSignature").range = strSignPath
    End with

    Set oDoc = nothing
    set oWord = nothing
    Cheers,
    Lennie

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    How 'bout this?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    This is code I used in Word 2002, I modified it slightly to match your code, it should work in Word 2003:
    Code:
      'HERE IS MY ORIGINAL CODE:
      'add header logo
      With ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, _
        FileName:=ActiveDocument.Path & "\logo.gif", _
        LinkToFile:=False, SaveWithDocument:=True)
        .WrapFormat.Type = 3
        .ZOrder 4
        .Name = "HeaderLogo"
      End With
    
      'HERE I MODIFIED IT TO WORK WITH YOUR CODE
      With oDoc.Shapes.AddPicture(Anchor:=oDoc.formfields("MgmrSignature").range, _
        FileName:="F:\SaleDept\ScanSignature\JohnHill.bmp", _
        LinkToFile:=False, SaveWithDocument:=True)
        .WrapFormat.Type = 3
        .ZOrder 4
        .Name = "SignatureImage"
      End With

  4. #4
    Join Date
    Jan 2005
    Location
    New Zealand
    Posts
    319
    Hi Ron,

    Thanks for your sample script.

    I have tried out your sample script and modified it to suit and it's working. Although it's working, how do I set the height and width of the .bmp signature on the WORD document ?

    Regarding these from your script what does it means:-
    .WrapFormat.Type = 3
    .ZOrder 4


    Once I get it going, I am gonna post the script here to share with others who may be interested in it.
    Last edited by Lennie; 11-12-2008 at 01:58 AM.
    Cheers,
    Lennie

  5. #5
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    Sure here is my original routine for adding a picture but with some comments
    for WrapFormat.Type and ZOrder. I included the Width and Height as well
    and there is also a Top and Left setting available if you need it.
    Code:
      With ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, _
        FileName:=ActiveDocument.Path & "\logo.gif", _
        LinkToFile:=False, SaveWithDocument:=True)
        'WrapFormat.Type sets how text is wrapped arround the image
        'wdWrapSquare=0 ,wdWrapTight=1 ,wdWrapThrough=2 ,wdWrapNone=3 ,wdWrapTopBottom=4 ,wdWrapInline=7
        .WrapFormat.Type = 3
        'ZOrder sets the overlap, that is what is on top of what
        'msoBringToFront=0 ,msoSendToBack=1 ,msoBringForward =2 ,msoSendBackward=3 ,msoBringInFrontOfText=4 ,msoSendBehindText=5
        .ZOrder 4
        .Width = PixelsToPoints(148)
        .Height = PixelsToPoints(53)
        '.Top = PixelsToPoints(27)
        '.Left = PixelsToPoints(252)
        .Name = "Logo"
      End With
    You can also access these properties after the picture is added using the
    Shapes and Selection objects.
    Code:
      ActiveDocument.Shapes.Range("Logo").Select
      Selection.ShapeRange.Top = PixelsToPoints(27)
      Selection.ShapeRange.Left = PixelsToPoints(252)
    There are other conversion functions also, not just PixelsToPoints()
    Like InchesToPoints(), or PointsToPixels(), PicasToPoints(), and more...

  6. #6
    Join Date
    Jan 2005
    Location
    New Zealand
    Posts
    319

    [RESOLVED] Using VB6 to transfer .BMP file to WORD 2003

    Hi Awesome Ron,

    Yee.....haaaaaa..............it's working very well now using the Height, Width, Top and Left properties, I managed to place the .bmp file image at the correct position on the WORD document.

    Man, Thank you very much for your help. If I am your boss, I will definitely give you a pay rise........

    I will copy my script later on and post it here to share with others who have similar problems.

    Have a good day, Ron.
    Cheers,
    Lennie

Similar Threads

  1. view word file
    By svn in forum VB Classic
    Replies: 7
    Last Post: 07-27-2005, 11:45 AM
  2. wav file fade in out help
    By jase_dukerider in forum C++
    Replies: 2
    Last Post: 04-14-2005, 08:48 PM
  3. updating xml file from VB6
    By smithg22 in forum VB Classic
    Replies: 9
    Last Post: 04-12-2005, 07:23 PM
  4. Replies: 3
    Last Post: 03-12-2005, 12:11 PM
  5. opening word doc, excel file etc
    By Sanjeev in forum ASP.NET
    Replies: 1
    Last Post: 11-16-2000, 02:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center