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
Solved

VBA in Word

Posted on 2012-03-16
2
332 Views
Last Modified: 2012-03-20
Hi Guys

I am trying to create a Word Macro.

I am using Maximizer CRM API.

I added a reference to the Maximizer Type Library.

Dim Company as string
Dim objMaxAttach As New MaximizerTLB.AttachToCurrentInstance    
        Dim objMaxCur As MaximizerTLB.CurrentRecord
        Dim objMaxApp As MaximizerTLB.Application
        objMaxCur = objMaxAttach.GetCurrentRecordObject      
        objMaxApp = objMaxAttach.GetApplicationObject

Company = objMaxCur.GetFieldValue("Company")

 objMaxApp = Nothing
        objMaxCur = Nothing    
        objMaxAttach = Nothing

It fails on  'objMaxCur = objMaxAttach.GetCurrentRecordObject ' with error object variable not set'.

If I step through code all Declarations are set to nothing. i.e objMaxAttach = 'Nothing'

This code works in visual studio 2008.

Thanks,
Shezad
0
Comment
Question by:Shezad Ahmed
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 37730253
You need to use Set for objects in VBA

Set objMaxCur = objMaxAttach.GetCurrentRecordObject      
Set objMaxApp = objMaxAttach.GetApplicationObject
0
 

Author Closing Comment

by:Shezad Ahmed
ID: 37741414
Thanks.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

840 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