The following excel VBA code is working perfectly fine and I am able to insert picture in "A1" cell. But with the following Access VBA code, I am getting "Type Mismatch" error at line #13.
Please kindly let me know how to solve this issue.
Thanks a million in advance!
Excel VBA:
Expand|Select|Wrap|Line Numbers
- Sub InsertPic()
- Dim myPict As Picture
- With ActiveSheet.Range("A1")
- Set myPict = .Parent.Pictures.Insert("C:\ExportFile\calendar.gif")
- myPict.Top = .Top
- myPict.Left = .Left
- myPict.Placement = xlMoveAndSize
- End With
- End Sub
Expand|Select|Wrap|Line Numbers
- Sub InsertPic()
- Dim xlApp As Excel.Application, xlWB As Excel.Workbook, xlWS As Excel.Worksheet
- Dim myPict As Picture
- Set xlApp = New Excel.Application
- With xlApp
- .Visible = True
- .Interactive = True
- Set xlWB = .Workbooks.Open("C:\Book1.xls", , False)
- Set xlWS = xlWB.Worksheets("Example")
- xlWS.Activate
- With xlWS.Range("A1")
- Set myPict = .Parent.Pictures.Insert("C:\ExportFile\calendar.gif")
- myPict.Top = .Top
- myPict.Left = .Left
- myPict.Placement = xlMoveAndSize
- End With
- End With
- Exit_Routine:
- Set xlApp = Nothing
- Set xlWB = Nothing
- Exit Sub
- End Sub