Solved

Is there a way to pick up the date picture was created when importing a picture via VBA

Posted on 2010-11-22
2
265 Views
Last Modified: 2012-08-13
Hi experts

I'm using the VBA code below to insert a picture into Word. I'm wondering if there is a way to pick up the date the picture was created as if it is before a certain date I need to handle it differently.
Dim oDialog As Word.Dialog, lngPictureSize As Double
 Set oDialog = Dialogs(wdDialogInsertPicture)
 Dim pic As InlineShape
 
  With oDialog
    .Display
    
Application.ScreenUpdating = False
    
    If .Name <> "" Then
             Set pic = ActiveDocument.InlineShapes.AddPicture(FileName:=.Name, _
            LinkToFile:=False, _
            SaveWithDocument:=True, _
            Range:=Selection.Range)

Open in new window

0
Comment
Question by:Fi69
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
ID: 34195206
This line:

            LinkToFile:=False, _

means that you can't do it later.


But you can do this to decide whether the picture is new enough to add to the document.
Dim oDialog As Word.Dialog, lngPictureSize As Double
    Dim pic As InlineShape
    Dim myDate As Date
    
    myDate = DateSerial(2009, 11, 23)
    
    Set oDialog = Dialogs(wdDialogInsertPicture)
    With oDialog
        .Display
        Application.ScreenUpdating = False
        If .Name <> "" Then
            If FileDateTime(.Name) > myDate Then
            
            Set pic = ActiveDocument.InlineShapes.AddPicture(FileName:=.Name, _
                      LinkToFile:=False, _
                      SaveWithDocument:=True, _
                      Range:=Selection.Range)

Open in new window

0
 

Author Closing Comment

by:Fi69
ID: 34200785
Perfect.
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question