Consulting

Results 1 to 6 of 6

Thread: Request: VBA Code Convert to Word 2010

  1. #1
    VBAX Newbie
    Joined
    Jan 2013
    Posts
    3
    Location

    Unhappy Request: VBA Code Convert to Word 2010

    Dear All,

    My colleague was using the MACRO for fetching the photos for its quality control work. The VBA code is defined to simplify their work for enhancing the maximum possible productivity in less time

    But now as the company has upgraded to the latest version of Microsoft Office Word 2007 to Microsoft Office Word 2010. The code is not supported to the newer version or perhaps the coding framework not supporting.

    I have also uploaded my screen shots for further clarification, if in case you need other info, please do let me know. But please expedite!

    Following is the VB Code:

    Dim pic(12), pictext(12)
    Dim fotoname(1000) As String
    Dim zahler, zahler2 As Integer
    Dim strA
    Private Sub Browse_Click()
    Location.Hide
    ChangeFileOpenDirectory ("C:\")
    Set opendialog = Dialogs(wdDialogFileOpen)
    opendialog.Display
    Path.Text = CurDir
    Location.Show
    End Sub
    Private Sub Cancel_Click()
    End
    End Sub
    Private Sub OK_Click()
    If OK.Value = False Then
    Location.Hide
    zahler2 = 1
    strA = 1
    Set fs = Application.FileSearch
    With fs
    .LookIn = Location.Path.Text
    .FileName = "*.*"
    If .Execute(SortBy:=msoSortByFileName, _
    SortOrder:=msoSortOrderAscending) > 0 Then
    MsgBox "There were " & .FoundFiles.Count & _
    " file(s) found."
    zahler = .FoundFiles.Count
    Selection.PageSetup.TopMargin = InchesToPoints(0.13)
    Selection.PageSetup.BottomMargin = InchesToPoints(0.25)
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    Selection.Font.Size = 14
    Selection.Font.Bold = wdToggle
    Selection.Font.Name = "Arial"
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2, NumColumns:= _
    2, DefaultTableBehavior:=wdWord9TableBehavior

    With Selection.Tables(1)
    .AllowAutoFit = False
    End With

    With Selection.Tables(1)
    .Borders(wdBorderLeft).LineStyle = wdLineStyleNone
    .Borders(wdBorderRight).LineStyle = wdLineStyleNone
    .Borders(wdBorderTop).LineStyle = wdLineStyleNone
    .Borders(wdBorderBottom).LineStyle = wdLineStyleNone
    .Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
    .Borders(wdBorderVertical).LineStyle = wdLineStyleNone
    .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
    .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
    .Borders.Shadow = False
    End With
    Selection.Tables(1).Select
    Selection.Rows.HeightRule = wdRowHeightExactly
    Selection.Rows.Height = InchesToPoints(3.1)

    Selection.TypeParagraph
    For i = 1 To .FoundFiles.Count
    fotoname(i) = .FoundFiles(i)
    HelpText = Len(fotoname(i))
    HelpText = Mid(fotoname(i), HelpText - 2, 3)
    If HelpText = "JPG" Or HelpText = "jpg" Or HelpText = "bmp" Or HelpText = "tif" Then


    Selection.InlineShapes.AddPicture FileName:=fotoname(i), _
    LinkToFile:=False, SaveWithDocument:=True
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    Selection.InlineShapes(1).Fill.Visible = msoFalse
    Selection.InlineShapes(1).Fill.Transparency = 0#
    Selection.InlineShapes(1).Line.Weight = 0.75
    Selection.InlineShapes(1).Line.Transparency = 0#
    Selection.InlineShapes(1).Line.Visible = msoFalse
    Selection.InlineShapes(1).LockAspectRatio = msoTrue
    Selection.InlineShapes(1).Height = 180#
    Selection.InlineShapes(1).Width = 239.75
    Selection.InlineShapes(1).PictureFormat.Brightness = 0.5
    Selection.InlineShapes(1).PictureFormat.Contrast = 0.5
    Selection.InlineShapes(1).PictureFormat.ColorType = msoPictureAutomatic
    Selection.InlineShapes(1).PictureFormat.CropLeft = 0#
    Selection.InlineShapes(1).PictureFormat.CropRight = 0#
    Selection.InlineShapes(1).PictureFormat.CropTop = 0#
    Selection.InlineShapes(1).PictureFormat.CropBottom = 0#
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.MoveLeft Unit:=wdCharacter, Count:=1
    Selection.TypeParagraph
    Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
    Selection.Font.Size = 11
    Selection.Font.Bold = wdToggle
    Selection.TypeText Text:="Pict. "
    Selection.TypeText Text:="0" + strA
    Selection.HomeKey Unit:=wdLine
    Selection.TypeText Text:=vbTab & " "
    Selection.EndKey Unit:=wdLine
    strA = strA + 1
    Selection.TypeParagraph
    Selection.MoveRight Unit:=wdCell
    Selection.TypeParagraph

    End If
    Next i
    End If
    End With
    End If
    End Sub

  2. #2
    VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,273
    Location
    Your code uses Application.FileSearch, which is not supported by either Office 2007 or Office 2010. Accordingly, that part of your code will have to be re-written. See the discussion at: http://answers.microsoft.com/en-us/o...8-84f28300dba4. You can download the class file referred to there from: http://dl.dropbox.com/u/35239054/FileSearch.cls

    PS: When posting code, please use the VBA button to apply formatting tags around it. They'll give your code a proper structure that makes it easier to read.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,273
    Location
    Cross-posted at: http://www.excelforum.com/word-forma...rd-2010-a.html
    For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    VBAX Newbie
    Joined
    Jan 2013
    Posts
    3
    Location
    Thanks for your sharing.

  5. #5
    VBAX Newbie
    Joined
    Jan 2013
    Posts
    3
    Location
    Thanks macropod for your suggestion i will have a look on. If i will get the desired output than it will be great otherwise i have to bother you again.

    I hope you will bear with me in.

    Regards,

    /imshah

  6. #6
    Thanks for your nice sharing. But using code is too complicated for me to solve the related conversion work. As for me, I prefer to do with the WORD conversion work with some fine 3rd party tools whose way of processing is simple and fast. For example, I used to convert Word to image with the help of the free trial package of an image and document tool. It is just one of many but I do appreciate its simple way of processing. Even though I only tried its free trial package to convert Word and didn′t check the cost and licensing conditions, it worked great for me. Besides, this site also gives a lot of tutorials about how to convert document image using C#.NET. Share with you. And I will try your sharing later. Thanks again.



    Best regards,
    Arron

Posting Permissions

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