473,383 Members | 1,855 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,383 software developers and data experts.

Turn off Name AutoCorrect with VBA?

BradHodge
166 Expert 100+
I am being stricken with the A2K Name AutoCorrect bug with regards to reports changing margins and orientation. I understand that you can turn this feature off when creating objects, but I am guessing (incorrectly I hope) that this will fix this problem only for my computer.

If this is indeed the case, does anyone know if it's possible to turn autocorrect off as soon as a user opens the database (via a vba module or something)?

Thanks!

Brad.
Apr 16 '07 #1
15 6459
Denburt
1,356 Expert 1GB
The following article explains how you can manually turn it off, if you need to use VBA let us know I am sure I can something to fit your needs.

"Taking the mystery out of Name AutoCorrect in Access."

http://office.microsoft.com/en-us/ac...345661033.aspx
Apr 16 '07 #2
BradHodge
166 Expert 100+
The following article explains how you can manually turn it off, if you need to use VBA let us know I am sure I can something to fit your needs.

"Taking the mystery out of Name AutoCorrect in Access."

http://office.microsoft.com/en-us/ac...345661033.aspx
__________________________________________________ ________________
Looks like that link you sent is no longer active (or just a problem with the site).

I have had no problem manually turning off Name AutoCorrect. I just need to know if you manually turn it off before creating Access objects, will this translate to other users PCs using the network version of the database?

If not... I do indeed need some advice on how to use VBA to turn off Name AutoCorrect.

Many thanks!
Apr 17 '07 #3
Denburt
1,356 Expert 1GB
I do believe this is a turned on and off per database type of an item. So if anyone is using that db then it should be set for them as well.

I do indeed need some advice on how to use VBA to turn off Name AutoCorrect.
That may take some effort I will try and do what I can if you or anyone else manages to find it please post it as it could be useful to others. Thanks
Apr 17 '07 #4
BradHodge
166 Expert 100+
Sweet! That's what I was hoping to hear. I am currently working on the first report I have built from scratch since turning off the AutoCorrect. I'll update you when I try it out.
Apr 17 '07 #5
BradHodge
166 Expert 100+
Well... Making progress, but...

It is now holding the Margins and the landscape orientation of the page, but it loses the "Legal" page size setting (reverts to Letter).

Thoughts?

Brad.
Apr 17 '07 #6
Denburt
1,356 Expert 1GB
In my module I typed in papersize highlighted it hit F1...Try that for AutoCorrect :)

Help file shows the following:
PaperSize Property
See AlsoApplies ToExampleSpecificsReturns or sets an AcPrintPaperSize constant indicating the paper size to use when printing. Read/write.

AcPrintPaperSize can be one of these AcPrintPaperSize constants.
acPRPS10x14
acPRPS11x17
acPRPSA3
acPRPSA4
acPRPSA4Small
acPRPSA5
acPRPSB4
acPRPSB5
acPRPSCSheet
acPRPSDSheet
acPRPSEnv10
acPRPSEnv11
acPRPSEnv12
acPRPSEnv14
acPRPSEnv9
acPRPSEnvB4
acPRPSEnvB5
acPRPSEnvB6
acPRPSEnvC3
acPRPSEnvC4
acPRPSEnvC5
acPRPSEnvC6
acPRPSEnvC65
acPRPSEnvDL
acPRPSEnvItaly
acPRPSEnvMonarch
acPRPSEnvPersonal
acPRPSESheet
acPRPSExecutive
acPRPSFanfoldLglGerman
acPRPSFanfoldStdGerman
acPRPSFanfoldUS
acPRPSFolio
acPRPSLedger
acPRPSLegal
acPRPSLetter
acPRPSLetterSmall
acPRPSNote
acPRPSQuarto
acPRPSStatement
acPRPSTabloid
acPRPSUser

expression.PaperSize
expression Required. An expression that returns one of the objects in the Applies To list.

Example
The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

Sub SetPrinter(strFormname As String)

DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
datamode:=acFormEdit, windowmode:=acHidden

With Forms(form1).Printer

.TopMargin = 1440
.BottomMargin = 1440
.LeftMargin = 1440
.RightMargin = 1440

.ColumnSpacing = 360
.RowSpacing = 360

.ColorMode = acPRCMColor
.DataOnly = False
.DefaultSize = False
.ItemSizeHeight = 2880
.ItemSizeWidth = 2880
.ItemLayout = acPRVerticalColumnLayout
.ItemsAcross = 6

.Copies = 1
.Orientation = acPRORLandscape
.Duplex = acPRDPVertical
.PaperBin = acPRBNAuto
.PaperSize = acPRPSLetter
.PrintQuality = acPRPQMedium

End With

DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
Save:=acSaveYes


End Sub
Apr 17 '07 #7
BradHodge
166 Expert 100+
I finally got it working.

As stated before, turning off the Name AutoCorrect made the report hold it's margins and Landscape orientation. However, the Paper Size continued to revert to Letter.

I ended up placing this code in the command button that opened the report...

DoCmd.OpenReport "MyReport", acViewPreview
MsgBox ("You must choose Paper Size: 'Legal' to view/print properly")
SendKeys "{RIGHT}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "%{DOWN}"
RunCommand acCmdPageSetUp

This opened Page SetUp and opened the dropdown box for choosing the paper size.

Thanks for all of your replies and direction Denburt!

Brad.
Apr 17 '07 #8
Denburt
1,356 Expert 1GB
I am glad you managed to get it working however, I so hate sendkeys... Yes they can get things done but they can be very problematic to say the least. I did a little digging and found the following article and I am sure you will find this useful.

http://support.microsoft.com/kb/290293


The link provides two methods of setting the default printer to legal as well as other properties and I am sure they will produce much more reliable results.
Apr 18 '07 #9
BradHodge
166 Expert 100+
Indeed this appears that it would be a much better method of accomplishing this task. However, it appears that it will only work on Access 2002, 03 and 07. This database is written in 2k. I have however marked this page for use on my next '03 Db!

Thanks again for your help.

Brad.
Apr 18 '07 #10
Denburt
1,356 Expert 1GB
You got me on that one drn everyone wants to complain today... lol Try this one, it is 2k compliant, I am so very stubborn. :)

http://support.microsoft.com/kb/302416/en-us
Apr 18 '07 #11
Denburt
1,356 Expert 1GB
You got me on that one drn everyone wants to complain today... lol Try this one, it is 2k compliant, I am so very stubborn. :)

http://support.microsoft.com/kb/302416/en-us

Sorry just realized it needs to open it in design view also... I will keep looking.
Apr 18 '07 #12
BradHodge
166 Expert 100+
You are quite stubborn... but if it ends up solving this one... I'll forgive a little stubborness :)
Apr 18 '07 #13
Denburt
1,356 Expert 1GB
Stuborn me I am back with more. I found two articles on printing using win32 API's if you think this may work for you let us know and we may be able to help with any conversions.
The code I am about to paste needs some work for printing a form etc. Basic printing to a default printer (worked for me) using the string in the code. I didn't try to make any adjustments to try and print a form. The one thing is the user will not see any dialog box, this can be remedied but you would need to design one.
The following article in this link refers to an issue with duplex printing however the code could possibly work with a few adjustments.
http://support.microsoft.com/kb/828638

This link is where I found the following code. The article states that this is for VB but it will work for VBA. I also made a few adjustments btw.
http://support.microsoft.com/kb/q154078/
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.       Private Type DOCINFO
  4.           pDocName As String
  5.           pOutputFile As String
  6.           pDatatype As String
  7.           pPaperSize As Integer
  8.       End Type
  9.       Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal _
  10.          hPrinter As Long) As Long
  11.       Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal _
  12.          hPrinter As Long) As Long
  13.       Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal _
  14.          hPrinter As Long) As Long
  15.       Private Declare Function OpenPrinter Lib "winspool.drv" Alias _
  16.          "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _
  17.           ByVal pDefault As Long) As Long
  18.       Private Declare Function StartDocPrinter Lib "winspool.drv" Alias _
  19.          "StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _
  20.          pDocInfo As DOCINFO) As Long
  21.       Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal _
  22.          hPrinter As Long) As Long
  23.       Private Declare Function WritePrinter Lib "winspool.drv" (ByVal _
  24.          hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, _
  25.          pcWritten As Long) As Long
  26.  
  27. Public sub RunPrint()
  28. Dim lhPrinter As Long
  29. Dim lReturn As Long
  30. Dim lpcWritten As Long
  31. Dim lDoc As Long
  32. Dim sWrittenData As String
  33. Dim MyDocInfo As DOCINFO
  34. lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0)
  35. If lReturn = 0 Then
  36.     MsgBox "The Printer Name you typed wasn't recognized."
  37.     Exit Sub
  38. End If
  39. MyDocInfo.pDocName = "AAAAAA"
  40. MyDocInfo.pOutputFile = vbNullString
  41. MyDocInfo.pDatatype = vbNullString
  42.  
  43. 'Not sure of the integer needed for legal play with it and see 
  44. debug.print  MyDocInfo.pPaperSize 
  45. MyDocInfo.pPaperSize = 1
  46.  
  47. lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
  48. Call StartPagePrinter(lhPrinter)
  49. sWrittenData = "How's that for Magic !!!!" & vbFormFeed
  50. lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _
  51.    Len(sWrittenData), lpcWritten)
  52. lReturn = EndPagePrinter(lhPrinter)
  53. lReturn = EndDocPrinter(lhPrinter)
  54. lReturn = ClosePrinter(lhPrinter)
  55. End Sub
Apr 19 '07 #14
BradHodge
166 Expert 100+
Hate to be dense, but compiler didn't like all the Private Declares after the 'End Type'. I looked specifically at the second link that you included and it said to put this code behind a command button. Is there more to it than that? My VBA experience thus far has not included placing all those Private Type, Private Declares and Public Subs one after the other.

Thanks,
Brad.
Apr 23 '07 #15
Denburt
1,356 Expert 1GB
Did you try and paste this into a brand new module? The you can simply call the subroutine RunPrint and off you go.
Apr 25 '07 #16

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

Similar topics

11
by: RdR | last post by:
Hi, I am using Q Replication, I need to set to logging to capture changes on a table but the table has more than 18 characters for the name, I looked at the docs, it mentioned that table names...
4
by: pippo | last post by:
Hello, I searched all over, and couldn't find code to change the Application's autocorrect options through VBA. Is this possible? I'm not talking about the Allow AutoCorrect of txt boxes or cbo...
4
by: Jim M | last post by:
Just got my copy of Access 2003. Is the 'Name Autocorrect' feature in Access 2003 fixed yet, or is it still 'Name Autocorrupt', as many in this newsgroup reported in the past. I would like to...
3
by: Regnab | last post by:
I'm not sure if this is some random bug in the system, but I keep getting the #Name? error on one of my forms when I try to link one field to another. For example, I have one field called...
2
by: Spawn666948 | last post by:
Hey, do you guys know how to set the Name Autocorrect to unchecked by default. Name Autocorrect is more trouble than its worth. I know I can go to Tools/General, but, I'd rather have it unchecked...
1
by: ApexData | last post by:
WatchOut for "Allow AutoCorrect" in your unbound combobox lookups. I am building a personnel database, and the last name of Ballance was causing the following message to popup, prohibiting me from...
0
by: =?Utf-8?B?TG92ZSBCdXp6?= | last post by:
Good day all. I am trying to set up MS Access to replace data in a cell using the AutoCorrect feature in Access. However, when I import a text file (.csv), it doesn't replace the cell as I have...
1
by: Simon | last post by:
Dear reader, By default the "Subdatasheet name" of a table is set to . If I change the setting to and save the changes the table property Subdatasheet name is still set to .
6
by: nagar | last post by:
I need to get the list of Autocorrect entries in word. Is there a way to do it without connecting to Word? Is the list saved somewhere? If I need to connect to Word, how can I detect if it's...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.