I have written the below function
what it does is either ceates a new playlist in itunes or if the same playlist exist it will not create a new playlist but just add files to the existing playlist
Public Function CopyAudioToiTunes()
PlaylistName = "Puja"
Set iTunesApp = CreateObject("iTunes.Application")
Dim Albumplaylist
Set Albumplaylist = iTunesApp.LibrarySource.Playlists.ItemByName(PlaylistName)
If Albumplaylist.Name <> PlaylistName Then
Set Albumplaylist = iTunesApp.CreatePlaylist(PlaylistName)
MsgBox "Creating new Playlist" & Albumplaylist.Name
End If
Dim FilesArray(0) As String
FilesArray(0) = mp3folder 'some global var defined before
Albumplaylist.AddFiles (FilesArray)
MsgBox ("Created playlists and added audio files to itunes.")
End Function
Its giving me an error:
object var not set
at this line : If Albumplaylist.Name <> PlaylistName Then
Basically i tried to check for all values like
if Albumplaylist = NULL then
or
if Alubumplaylist = "" then
but its still giving me an error
Could someone pls suggest me what condition to look for when the playlist does not exist.
Thanks
what it does is either ceates a new playlist in itunes or if the same playlist exist it will not create a new playlist but just add files to the existing playlist
Public Function CopyAudioToiTunes()
PlaylistName = "Puja"
Set iTunesApp = CreateObject("iTunes.Application")
Dim Albumplaylist
Set Albumplaylist = iTunesApp.LibrarySource.Playlists.ItemByName(PlaylistName)
If Albumplaylist.Name <> PlaylistName Then
Set Albumplaylist = iTunesApp.CreatePlaylist(PlaylistName)
MsgBox "Creating new Playlist" & Albumplaylist.Name
End If
Dim FilesArray(0) As String
FilesArray(0) = mp3folder 'some global var defined before
Albumplaylist.AddFiles (FilesArray)
MsgBox ("Created playlists and added audio files to itunes.")
End Function
Its giving me an error:
object var not set
at this line : If Albumplaylist.Name <> PlaylistName Then
Basically i tried to check for all values like
if Albumplaylist = NULL then
or
if Alubumplaylist = "" then
but its still giving me an error
Could someone pls suggest me what condition to look for when the playlist does not exist.
Thanks