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
264 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 May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

738 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