473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Object Variable Or With Block Variable Not Set

Hi everybody... I've been working on moving access data to a word document for the last 10 days but keep getting stuck. The latest problem is that i'm getting the error "Object Variable Or With Block Variable Not Set". The code is as follows.

Dim objWord As New Word.Document
Set objWord=GetObject("C:\Abc.doc")
objWord.Application.Visible=True

objWord.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="TABLE BasicDetails", _
SQLStatement:="Select * FROM BasicDetails"
objWord.MailMerge.Execute


Also, is there any other way to send data from a form to a Word Document (where the form is displaying certain rows from a table)?
Jun 15 '07 #1
2 3408
MMcCarthy
14,534 Expert Mod 8TB
It doesn't look like the error is in this piece of code. This error normally occurs when you haven't closed a loop, if statement, etc.

Post the full code of this procedure if you can't find it.
Jun 17 '07 #2
ADezii
8,834 Expert 8TB
Hi everybody... I've been working on moving access data to a word document for the last 10 days but keep getting stuck. The latest problem is that i'm getting the error "Object Variable Or With Block Variable Not Set". The code is as follows.

Dim objWord As New Word.Document
Set objWord=GetObject("C:\Abc.doc")
objWord.Application.Visible=True

objWord.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="TABLE BasicDetails", _
SQLStatement:="Select * FROM BasicDetails"
objWord.MailMerge.Execute


Also, is there any other way to send data from a form to a Word Document (where the form is displaying certain rows from a table)?
Try making your Declaration in a Form Module or Standard Code Module. It looks as though objWord is declared in a Local Procedure, its Reference to the Word Document may be going out of scope (after the Procedure ends) before the code has time to fully execute. This could definately cause an "Object Variable Or With Block Variable Not Set" Error.
Expand|Select|Wrap|Line Numbers
  1. 'In a Form Code Module
  2. Dim objWord As New Word.Document
  3.  
  4. 'In a Standard Code Module (Scope = Global)
  5. Public objWord As New Word.Document
Jun 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: Hung Jung Lu | last post by:
Hi, Does anybody know where this term comes from? "First-class object" means "something passable as an argument in a function call", but I fail to see the connection with "object class" or...
10
by: Michael McCracken | last post by:
Hi, I have a problem with unittest.TestCase that I could really use some help with. I have a class File in module File. The important thing about File for this discussion is that it's simple -...
8
by: Lauren Quantrell | last post by:
I get the following error: "Object variable or Width block variable not set error" trying to run this in my Access2000 .ADP database: CurrentDb.Properties.Append...
8
by: Mark Neilson | last post by:
1. What is the best way to make a single instance of my top level class (DLL) internally available to all other members of the assembly? The top level object is where all other access is made in...
6
by: Neo Geshel | last post by:
I am trying to deal with an image in code-behind. I consistently get the following error: Server Error in '/' Application. Object variable or With block variable not set. Description: An...
44
by: petermichaux | last post by:
Hi, I have been using the following line of code to create an object called "Serious" if it doesn't already exist. if (Serious == null) {var Serious = {};} This works in the scripts I use...
3
by: Richard Hollenbeck | last post by:
I've marked the line in this subroutine where I've been getting this error. It may be something stupid but I've been staring at this error trying to fix it for over an hour. I'm pretty sure the...
1
by: abhijmenbumca07 | last post by:
Object variable or With block variable not set. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information...
4
by: BrianAdev | last post by:
Why It throw an error of <Object variable or With block variable not set> set objAccess = GetObject(strMdbPath) objAccess.DoCmd.SetWarning False objAccess.DoCmd.OpenReport strReportName, 0 'It...
3
by: Newbie19 | last post by:
I'm trying to get a list of all subfolders in a folder on a share drive, but I keep on getting this error message: Object variable or With block variable not set. Description: An unhandled...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.