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

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 4412
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.