Adwords API, COM and VBA

476 views
Skip to first unread message

groucho

unread,
May 20, 2012, 2:04:06 PM5/20/12
to adwor...@googlegroups.com
Hi all,

Another question concerning VBA access to Adwords API in the forum. I hope I could write a complete walkthrough for VBA user after that.

I've recompiled the Common and Adwords librairies with COM visibility, and trying to make a simple AccountCreation example conversion from VB to VBA but I can't (don't know more exactly) how to call from VBA the ServiceSignature  AdWordsService.v201109_1.CreateAccountService. I believe it's more a VB2VBA language conversion problem (object instantiation) than a API issue.

Private Sub CommandButton1_Click()

    Dim user As Google_AdWords.AdWordsUser

    Set user = New Google_AdWords.AdWordsUser

    ' Get the CreateAccountService.
      Dim createAccountService As Google_AdWords.Google_Api_Ads_AdWords_v201109_1_CreateAccountService
      
      Set createAccountService = user.GetService(...)

The original code is :

      Dim createAccountService As CreateAccountService = user.GetService( _
          AdWordsService.v201109_1.CreateAccountService)

Does anyone know how to go from the VB to the VBA code ?

Very precise question, but it seems to be my last issue before using adwords api from VBA (Excel, Access)... 

Thanks for your help ! 

- DB.

Anash P. Oommen

unread,
May 22, 2012, 10:21:33 AM5/22/12
to adwor...@googlegroups.com
Hi,

I've never tried doing com interop with the AdWords API .NET library, but I think you will have better chances of making it work if you were to write a simple com-interop utility library in VB.NET/C# that uses the client library to perform tasks and call that utility library from VBA. If you use the library as such, I suspect you will have issues when VBA tries to call overloaded constructors, methods, etc. VBA isn't as object-oriented as VB.NET.

See http://jumbloid.blogspot.in/2009/12/making-net-dll-com-visible.html for details on how to write a comvisible assembly.

Cheers,
Anash P. Oommen,
AdWords API Advisor.

groucho

unread,
May 22, 2012, 11:50:42 AM5/22/12
to adwor...@googlegroups.com
Hi,

Thanks for your answer. You're right and actually the main issue is about static classes (like AdWordsService.v201109_1.CreateAccountService) that are not handled by COM and VBA. 

Your solution will certainly work, and should be not to hard to code (I'm not a .NET developer, but it seems reachable).

Thanks,

- DB.

Anash P. Oommen

unread,
May 23, 2012, 2:12:57 AM5/23/12
to adwor...@googlegroups.com
Hi,

Could you also open a feature request at  http://code.google.com/p/google-api-adwords-dotnet/issues/list to make the library more com interop friendly? I have seen classic ASP developers also ask similar questions in the past, may be having a com-interop wrapper library for AdWords .NET library can benefit some of them.

Cheers,
Anash P. Oommen,
AdWords API Advisor.

James Scott

unread,
May 23, 2012, 8:47:35 AM5/23/12
to adwor...@googlegroups.com
Hi Groucho

 Please can you post back if you complete a walkthrough, I'm having a devil of a time trying to get anywhere with VBA and the Adwords API.

 Thanks!
Reply all
Reply to author
Forward
0 new messages