Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-09-2017, 12:27 PM
michissimo michissimo is offline Automatic picture importing into a table Windows 7 64bit Automatic picture importing into a table Office 2013
Novice
Automatic picture importing into a table
 
Join Date: Oct 2017
Posts: 10
michissimo is on a distinguished road
Default Automatic picture importing into a table

Hi everyone,



I need to create a Script, who allow to import all the picture inside a folder in a Table in Word.
- Every picture must stay in a different cell.
- The table has 2 Row, all the picture have to stay in the links row.


I've found this script that allow to import all the picture form a folder into a word document, but i've no idea how modify it, so that he can import them into a Table.

Code:
Sub InsertImage()
    Dim FolderPath, objFSO, Folder, ImagePath, image
    Const END_OF_STORY = 6
    Const MOVE_SELECTION = 0
    FolderPath = Select_Folder_From_Prompt
    If InStr(FolderPath, "EMPTY") = 0 Then
        Set objFSO = CreateObject("Scripting.Filesystemobject")
        Set Folder = objFSO.GetFolder(FolderPath)
        For Each image In Folder.Files
            ImagePath = image.Path
            If CheckiImageExtension(ImagePath) = True Then
                'Insert the images into the word document
                Application.Selection.EndKey END_OF_STORY, MOVE_SELECTION
                Application.Selection.InlineShapes.AddPicture (ImagePath)
                Application.Selection.InsertBreak  'Insert a pagebreak
            End If
        Next
    End If
End Sub


Function Select_Folder_From_Prompt() As String
     
    Dim fd, bMultiSelect, CONST_MODEL_DIRECTORY
    Set fd = Application.FileDialog(msoFileDialogFolderPicker)
     
    With fd
        .Title = "Select a folder"
        .AllowMultiSelect = bMultiSelect
        .InitialFileName = CONST_MODEL_DIRECTORY
        .Filters.Clear
         
         'Use the Show method to display the File Picker dialog box and return the user's action.
         'The user pressed the action button.
        If .Show = -1 Then
            Select_Folder_From_Prompt = .SelectedItems(1) & "\"
        Else
            Select_Folder_From_Prompt = "EMPTY"
        End If
    End With
     
End Function


Function CheckiImageExtension(ImagePath)
    Dim varArray        ' An array contains iamge file extensions.
    Dim varEach         ' Each iamge file extension.
    Dim blnIsPptFile    ' Whether the file extension is image file extension.
    Dim objFSO, file, FileExtension
    Set objFSO = CreateObject("Scripting.Filesystemobject")
    Set file = objFSO.GetFile(ImagePath)
    FileExtension = file.Name
    blnIsPptFile = False
    If FileExtension <> "" Then
        varArray = Array(".emf", ".wmf", ".jpg", ".jpeg", ".jfif", ".png", ".jpe", ".bmp", ".dib", ".rle", ".gif", ".emz", ".wmz", ".pcz", ".tif", ".tiff", ".eps", ".pct", ".pict", ".wpg")
        For Each varEach In varArray
            If InStrRev(UCase(FileExtension), UCase(varEach)) <> 0 Then
                blnIsPptFile = True
                Exit For
            End If
        Next
    End If
    CheckiImageExtension = blnIsPptFile
    Set objFSO = Nothing
    Set file = Nothing
End Function
Can someone help me?
Reply With Quote
  #2  
Old 10-09-2017, 01:26 PM
macropod's Avatar
macropod macropod is offline Automatic picture importing into a table Windows 7 64bit Automatic picture importing into a table Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See: https://www.msofficeforums.com/word-...html#post47919
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-10-2017, 01:54 AM
michissimo michissimo is offline Automatic picture importing into a table Windows 7 64bit Automatic picture importing into a table Office 2013
Novice
Automatic picture importing into a table
 
Join Date: Oct 2017
Posts: 10
michissimo is on a distinguished road
Default

Thank you!!
Reply With Quote
Reply

Tags
picture, table



Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing number data from an Excel spreadsheet into a Word table Hefty Word Tables 1 06-07-2017 04:08 AM
Automatic picture importing into a table Importing Data from Excel - Format of table messed up in Word Table epsulliv Word Tables 6 08-24-2015 07:29 AM
Automatic picture importing into a table Automatic change of Picture Captions... pawleex Word 1 08-04-2013 05:04 PM
Automatic picture importing into a table Problem with automatic table of contents pogonoforysci1 Word 14 04-14-2013 10:39 PM
Automatic picture importing into a table Formatting automatic table of contents 1234msaps Word 3 10-31-2012 02:26 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft