473,471 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using PrtDevMode en PrtDevNames of MS Access Scripting lib in VB.NET

Hi,

Can anyone give me sample code on how to use de info in PrtDevMode en
PrtDevNames of Access from within VB.NET?

This is how it's done in VB6:
http://msdn.microsoft.com/library/de...HV05187912.asp

I tried redefining the type declarations in VB.NET using structures:
Private Structure str_DEVMODE
<VBFixedString(94)> Public RGB As String
End Structure
Private Structure type_DEVMODE
<VBFixedString(32)> Public strDeviceName As String
Public intSpecVersion As Integer
Public intDriverVersion As Integer
Public intSize As Integer
Public intDriverExtra As Integer
Public lngFields As Long
Public intOrientation As Integer
Public intPaperSize As Integer
Public intPaperLength As Integer
Public intPaperWidth As Integer
Public intScale As Integer
Public intCopies As Integer
Public intDefaultSource As Integer
Public intPrintQuality As Integer
Public intColor As Integer
Public intDuplex As Integer
Public intResolution As Integer
Public intTTOption As Integer
Public intCollate As Integer
<VBFixedString(32)> Public strFormName As String
Public lngPad As Long
Public lngBits As Long
Public lngPW As Long
Public lngPH As Long
Public lngDFI As Long
Public lngDFr As Long
End Structure

But now I have no idea how to get the info of rpt.PrtDevMode into these
structures... When I try to assign rpt.PrtDevMode to a String variable
like in the VB6 code, I get a cast error because rpt.PrtDevMode is an
array of bytes. So I tried converting that in a proper way using
BitConverter.ToString but that gives a different String as in VB6 so
that doesn't work.

Anyone knows how I can do that?

Veerle

Nov 21 '05 #1
2 4417
Hi Veerle,

I believe you should do the following (quick-&-dirty sample):

~
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> Private
Structure DevMode_Access
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public
DeviceName As String
Public SpecVersion As Int16
Public DriverVersion As Int16
Public Size As Int16
Public DriverExtra As Int16
Public Fields As Int32
Public Orientation As Int16
Public PaperSize As Int16
Public PaperLength As Int16
Public PaperWidth As Int16
Public Scale As Int16
Public Copies As Int16
Public DefaultSource As Int16
Public PrintQuality As Int16
Public Color As Int16
Public Duplex As Int16
Public YResolution As Int16
Public TTOption As Int16
Public Collate As Int16
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public
FormName As String
Public Pad As Int32
Public Bits As Int32
Public PW As Int32
Public PH As Int32
Public DFI As Int32
Public DFR As Int32
End Structure

Private Sub Form1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Click
Dim Acc As New Access.Application
Acc.OpenCurrentDatabase("D:\Program Files\Microsoft
Office\Office\Samples\Áîðåé.mdb")
Dim Cat As Access.Report
Acc.DoCmd.OpenReport("Êàòàëîã", Access.AcView.acViewDesign)
Cat = Acc.Reports(0)
Acc.Visible = True
Dim DM As DevMode_Access
DM =
CType(Marshal.PtrToStructure(Marshal.UnsafeAddrOfP innedArrayElement(CTyp
e(Cat.PrtDevMode, Byte()), 0), GetType(DevMode_Access)), DevMode_Access)
Stop
End Sub
~

I hope this gives an idea,
Roman
Nov 21 '05 #2
> Hi Veerle,

I believe you should do the following (quick-&-dirty sample):
DM =
CType(Marshal.PtrToStructure(Marshal.UnsafeAddrOfP innedArrayElement(CTyp
e(Cat.PrtDevMode, Byte()), 0), GetType(DevMode_Access)), DevMode_Access)

I hope this gives an idea,
Roman


Yes it does! This is exactly what I was looking for! Thanks a lot!
Veerle

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lin Ma | last post by:
Greetings, Is it possbile to check a file exist without using Server.CreateObject("Scripting.FileSystemObject") in asp page?? The reason is our hosting company turn that function off for...
6
by: Jeff T. | last post by:
All, Is there any way to access a separate IE 6.0 browser process via the Javascript DOM ? For example, open IE once. Open IE again (not using File->New). Can the second IE browser/process...
3
by: Laurie | last post by:
I am using Automation in Access 2003 to open a Word Document and fill in some values using bookmarks. It all works perfectly except for one section. I am filling in some values in a previously...
0
by: hansiman | last post by:
How do I read a stored proc return value ( return(@return_value) ) using MS Data Access Application Block. Normally I use: Dim conn As SqlConnection = New SqlConnection("connectionstring")...
0
by: veerleverbr | last post by:
Hi, Can anyone give me sample code on how to use de info in PrtDevMode en PrtDevNames of Access from within VB.NET? This is how it's done in VB6:...
4
by: korund | last post by:
Is there any difference to read & write to windows Registry with VBScript or JavaScript? Both scripting languages have similar syntax. What is preferable use for this? thanks.
13
by: Leslie Coover | last post by:
I want to script real-time data FROM financial Web sites TO an MS Access db. on a PC (no server issues). Is this possible? If so what should I use ASP VBScript, ASP.NET VB or something else,...
2
by: prakharv | last post by:
Hi All, I would like to upload an image file from my web page to the server using C(CGI scripting). Actually I am able to upload a text file using gcgi library but not image file. Please, if...
2
by: 121NetDesign | last post by:
Help Please First time question. Creating a simple cms website using asp and access. Problem I am having is how to display an image from a folder one level up. This is what I use 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.